<form name="testform" onclick="test()">
<input type="checkbox">
<input type="checkbox">
<input type="checkbox">
<input type="submit">
</form><script>
function test()
{
var checked = false ;
with(event.srcElement)
if(checked==true)
for(i=0; i<parentElement.children.length; i++)
if(parentElement.children[i].type=="checkbox")
parentElement.children[i].checked = true ;
}
</script>

解决方案 »

  1.   

    <script language="javascript">
    <!--
      function  fnccheck(o1)
      {
        if(o1.checked)
        {
          var o2 = document.getElementsByTagName('INPUT')
          for(var i=0;i<o2.length;i++)
          {
            if(o2[i].type == 'checkbox') o2[i].checked = true;
          }
        }
      }
    //-->
    </script><input type=checkbox onclick='fnccheck(this);'>
    <input type=checkbox onclick='fnccheck(this);'>
    <input type=checkbox onclick='fnccheck(this);'>
      

  2.   

    上面的哥们都写得那么长,我也只好写全了凑个长度。<html>
    <head>
    <script language="vbscript">
    sub button1_onclick
    for each i in form1
    i.checked=not i.checked
    next 
    end sub
    </script>
    <title>无标题文档</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body bgcolor="#FFFFFF" text="#000000">
    <form name="form1">
    <input type="checkbox" >
    <input type="checkbox" >
    <input type="checkbox" >
    <input type="button" name="button1" value="click">
    </form>
    </body>
    </html>
      

  3.   

    最直接的写法就是
    <input type="checkbox" onclick="selectAll()"....
    function selectAll(){
        chkboxa.checked=true;
        chkboxb.checked=true;
        chkboxc.checked=true;
            ....
    }
      

  4.   

    是在checkbox上打勾,给它取个名吧button1