o = document.getElementsByName("ttt")
for(i=0;i<o.length;i++) o[i].checked=true

解决方案 »

  1.   

    如当我点击一下链接
    <a href=#>1</a><a href=#>2</a>复选择框:
    <INPUT TYPE="checkbox" NAME="ttt1" value="1">test1
    <INPUT TYPE="checkbox" NAME="ttt2" value="1">test2
    <INPUT TYPE="checkbox" NAME="ttt3" value="1">test3
    <INPUT TYPE="checkbox" NAME="ttt4" value="1">test4
    <INPUT TYPE="checkbox" NAME="ttt5" value="1">test5
    <INPUT TYPE="checkbox" NAME="ttt6" value="1">test6分类打上勾,如点击1,复选框ttt1,ttt3,ttt5打勾
    分类打上勾,如点击2,复选框ttt2,ttt4,ttt6打勾
      

  2.   

    target.click();
    target.checked=true;
      

  3.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>全选、反选、全不选</title>
    <script language="javascript">
    <!--
      function SelectIterm(form,sign)
        {
      for (var i=0;i<form.elements.length;i++){
        if(form.elements[i].type=='checkbox'){
           var e=form.elements[i]
            if (sign==0) e.checked=true;
    if(sign==1) e.checked=!e.checked;
    if(sign==2) e.checked=false;}
     
    }} 
    -->
    </script>
    </head>
    <body>
    <form name="myform" >
    <table width="576" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td width="101" height="27" valign="top"><input type="checkbox" name="checkbox7" value="checkbox"></td>
        <td width="111" valign="top"><input type="checkbox" name="checkbox8" value="checkbox"></td>
        <td width="364" valign="top"><input type="checkbox" name="checkbox9" value="checkbox"></td>
      </tr>
      <tr>
        <td height="24" valign="top"><input type="checkbox" name="checkbox6" value="checkbox"></td>
        <td valign="top"><input type="checkbox" name="checkbox5" value="checkbox"></td>
        <td valign="top"><input type="checkbox" name="checkbox4" value="checkbox"></td>
      </tr>
      <tr>
        <td height="25" valign="top"><input type="checkbox" name="checkbox3" value="checkbox"></td>
        <td valign="top"><input type="checkbox" name="checkbox2" value="checkbox"></td>
        <td valign="top"><input type="checkbox" name="checkbox1" value="checkbox"></td>
      </tr>
      <tr>
        <td height="35" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
      </tr>
      <tr>
        <td height="33" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
      </tr>
      <tr>
        <td height="35" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
      </tr>
      <tr>
        <td height="33" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
      </tr>
      <tr>
        <td height="18" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
      </tr>
    </table>
    <a href="javascript:SelectIterm(myform,0);">全选</a>
    <a href="javascript:SelectIterm(myform,1);">反选</a>
    <a href="javascript:SelectIterm(myform,2);">全不选</a>
    </form>
    </body>
    </html>