<td >标题文字:<input name="fb" type="checkbox" value=""  id =check<%= i %> onclick="this.parentNode.backGroundColor='yellow'"></td>

解决方案 »

  1.   

    改下
    <input name="fb" type="checkbox" value=""  id ="check" onclick="this.parentNode.style.backgroundColor='yellow'">
      

  2.   

    感谢.这一步是可以做到点击就变色.但有个问题:
    因为有些checkbox我要预先选中,那么页面执行后,不管是选中的还是没选中的,底色都是白色.
    可不可以根据选中与否来确定底色?
    <input name="fb" type="checkbox" value=""  id ="check" onclick="this.parentNode.style.backgroundColor='yellow'" <% if right(rs("mc"),1)=1 then reponse.write "checked" %>>
      

  3.   

    <script language="JavaScript" type="text/JavaScript">
    function ch(is)
    {
    if(is.checked==true)
    {
    is.parentNode.style.backgroundColor='yellow';
    }
    else
    {
    is.parentNode.style.backgroundColor='';
    }
    }
    </script><table>
     <tr>
        <td><input name="checkbox1" type="checkbox" id="checkbox1"  value="checkbox"  onClick="ch(this)"></td>
        <td><input type="checkbox" name="checkbox" value="checkbox" onClick="ch(this)"></td>
      </tr></table>
      

  4.   

    function fun(){
       var a=document.getElementsByTagName("input");
       for(var i=0;i<a.length;i++){
          if(a[i].type=='checkbox'){
             if(a[i].checked==true){
                a[i].parentNode.style.backgroundColor='yellow';
             }
          }
       }
    }
      

  5.   

    谢谢.
    经测试,选中为黄色,不选中为白色已可达到目标.
    但是页面刚打开的时候checkbox为选中的情况下底色还是白色的.
    有没有好办法在页面初始的时候做一次判断?俺只学过VB,对JAVA是一点不知.
      

  6.   

    function init()
    {
    //do somthing
    }
    <body onload="init()">
    这个方法在页面load的时候会做的
      

  7.   

    <body onload="fun()">function fun(){
       var a=document.getElementsByTagName("input");
       for(var i=0;i<a.length;i++){
          if(a[i].type=='checkbox'){
             if(a[i].checked==true){
                a[i].parentNode.style.backgroundColor='yellow';
             }
          }
       }
    }
      

  8.   

    mingxuan3000(铭轩) 的方法可行.
    THANKS.
    结贴.