<table width="100%" height="70%" align="center" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<form id="QueryForm" action="query.asp?action=Query" method="post" >
<table id="op" name="op" width="700" align="center" bgcolor="#aaaaaa" class="common-text" cellpadding="3" cellspacing="1" border="0"> <tr bgcolor="#ffffff" height="20">
<td width="80">中继线</td>
<td><input type="checkbox" name="chkTrunkLine" id="chkTrunkLine" onclick="CheckFace(this,txtTrunkLine);" language="javascript"><input type="text" name="txtTrunkLine" value="" class="text-face" disabled></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<script language="javascript">
//<!--
function CheckFace(oCheck,obj)
{
if (oCheck.checked==true)
{
obj.style.backgroundColor="#ffffff";
obj.disabled=false;
}
else
{
obj.style.backgroundColor="#eeeeee";
obj.disabled=true;
}
}
//-->
</script>注意区分大小写

解决方案 »

  1.   

    <table width="100%" height="70%" align="center" cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td>
    <form name="QueryForm" action="query.asp?action=Query" method="post" >
    <table id="op" name="op" width="700" align="center" bgcolor="#aaaaaa" class="common-text" cellpadding="3" cellspacing="1" border="0"> <tr bgcolor="#ffffff" height="20">
    <td width="80">中继线</td>
    <td>
    <input type="checkbox" name="chkTrunkLine" id="chkTrunkLine" onclick="CheckFace(this,'txtTrunkLine');" language="javascript">
    <input type="text" name="txtTrunkLine" value=""class="text-face" disabled>
    </td>
    </tr>
    </table>
    </form>
    </td>
    </tr>
    </table>
    <script language="javascript">
    function CheckFace(oCheck,objname)
    {
    var obj = MM_findObj_(objname);

    if (oCheck.checked==true)
    {
    alert('aaaa');
    obj.style.backgroundColor="#ffffff";
    obj.disabled=false;
    }
    else
    {
    alert('bbbb');
    obj.style.backgroundColor="#eeeeee";
    obj.disabled=true;
    }
    }function MM_findObj_(n, d)

    var p,i,x;  

    if(!d) 
    d=document; 

    if((p=n.indexOf("?"))>0&&parent.frames.length) 
    {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
    }
    if( !(x=d[n]) && d.all ) 
    x=d.all[n]; 

    for (i=0;!x&&i<d.forms.length;i++) 
    x=d.forms[i][n];

    for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
    x=MM_findObj_(n,d.layers[i].document); 

    return x;
    }</script>
      

  2.   

    以上代码是好用的,谢谢
    但是放到我的网页就有问题了if((p=n.indexOf("?"))>0&&parent.frames.length) 这句同不过,说没有找到方法