function checkAll(checkboxname){
    var checks = document.getElementsByName(checkboxname);
    for(var i=0;i<checks.length;i++){
      var obj = checks[i];
      obj.checked = true;
    }       
}<input name="checkAll" onclick="checkAll('check')" type="checkbox">
<input name="check" type="checkbox">
<input name="check" type="checkbox">

解决方案 »

  1.   

    <script>
    function ys()
      {var c=document.getElementsByTagName("INPUT");
       var l=c.length;
       var i;
       for(i=0;i<l;i++)
         if(c[i].type=="checkbox")
           c[i].checked=true;
      }
    </script>
    <button onclick=ys()>Select All</button>
    <input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox><input type=checkbox>
      

  2.   

    function button1_click()
    {
       for(var i=0;i<document.all;i++)
       {
          if (document.all(i).type=="checkbox") {
              document.all(i).check=true
          }
       }
    }
      

  3.   

    function checkAll(){
        var s = document.getElementsByName('check');
        for(var i=0;i<s.length;i++){
          s[i].checked = true;
        }       
    }<input name="checkAll" onclick="checkAll()" type="button" value="全选">
    <input name="check" type="checkbox">
    <input name="check" type="checkbox">
      

  4.   

    onclick="for(i=0;i<document.form.chkbox.length;i++){document.form.chkbox[i].checked=(this.checked)?true:false}"
      

  5.   

    <script>
    function ys()
      {var c=document.getElementsByTagName("INPUT");
       var l=c.length;
       var i;
       for(i=0;i<l;i++)
         if(c[i].type=="checkbox")
           c[i].checked=true;
      }
    </script>
    <button onclick=ys()>Select All</button>
      

  6.   

    Apollo47(阿波罗) ( ) 信誉:100 
    头一次看到啊,老兄,好啊。