<input type=checkbox>
<br>
<input type=checkbox>
<br>
<input type=checkbox>
<br>
<input type=checkbox>
<br>
<input type=checkbox>
<script>
function checkAll(el)
{
  var ingc;
  for (ingc=0;ingc<document.all.length;ingc++)
  {
    if (document.all(ingc).type == 'checkbox') document.all(ingc).checked = el.checked;
  }
}
</script>
<br>
全选 
<input name="checkbox" type=checkbox onclick='checkAll(this)' value='全选'>

解决方案 »

  1.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    <meta name="Generator" content="EditPlus">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    </head><body>
    <input type=checkbox>
    <br>
    <input type=checkbox>
    <br>
    <input type=checkbox>
    <br>
    <input type=checkbox>
    <br>
    <input type=checkbox>
    <script>
    function checkAll()
    {
      var ingc;
      for (ingc=0;ingc<document.all.length;ingc++)
      {
        if (document.all(ingc).type == 'checkbox') document.all(ingc).checked = event.srcElement.checked;
      }
    }
    </script>
    <br>
    全选 
    <input name="checkbox" type=checkbox onclick='checkAll()' value='全选'>
    </body>
    </html>
    ----------------
    true; 改成event.srcElement.checked;
      

  2.   

    ok,ok~~~<input type=checkbox>
    <br>
    <input type=checkbox>
    <br>
    <input type=checkbox>
    <br>
    <input type=checkbox>
    <br>
    <input type=checkbox>
    <script>
    function checkAll(blnNote)
    {
      var ingc;
      for (ingc=0;ingc<document.all.length;ingc++)
      {
        if (document.all(ingc).type == 'checkbox' && document.all(ingc).name != 'checkbox') 
        {
            document.all(ingc).checked = blnNote;
        }
      }
    }
    </script>
    <br>all selected<input name="checkbox" type=checkbox onclick='checkAll(this.checked)' value='all selected'>
      

  3.   

    <input type=checkbox>1
    <input type=checkbox>1
    <input type=checkbox>1
    <input type=checkbox>1
    <br>
    <input type="button" value="全选" onclick="doCheckBox(1)">
    <input type="button" value="全不选" onclick="doCheckBox(2)">
    <input type="button" value="反选" onclick="doCheckBox(3)">
    <script>
    function doCheckBox(iType)
    {
    //1:全选;2:全不选;3:反选;
    for(iIndex=0;iIndex<document.all.length;iIndex++)
    {
    if(document.all(iIndex).type=="checkbox")
    {
    switch(iType)
    {
    case 1:document.all(iIndex).checked=true;break;
    case 2:document.all(iIndex).checked=false;break;
    case 3:{if(document.all(iIndex).checked==true){document.all(iIndex).checked=false;}else{document.all(iIndex).checked=true;}}break;
    }
    }
    }
    }
    </script>