<table width="16%" border="1" style='table-layout:fixed;'>
  <tbody>
    <tr valign="top">
      <td width="4%" height="24" align="center"><input name="check" type="checkbox"  onClick="add_id(1)" value="26" ></td>
      <td height="24" align="center">&nbsp;</td>
    </tr>
    <tr valign="top">
      <td height="24" align="center"><input name="check" type="checkbox"  onClick="add_id(2)" value="18" ></td>
      <td height="24" align="center">&nbsp;</td>
    </tr>
    <tr valign="top">
      <td height="24" align="center"><input name="check" type="checkbox"  onClick="add_id(3)" value="17" ></td>
      <td height="24" align="center">&nbsp;</td>
    </tr>
  <input name="all_sel" type="hidden" value="26,18,17,16,15,14,">
  <tr>
    <td colspan="2" align="center"><input type="checkbox" name="all_select()" value="checkbox" onClick="document.getElementById('check').checked=this.checked">
      全选
      
      <input type="checkbox" name="un_select" value="checkbox">
      反选 <br>
      <input name="but_del" type="button" onClick="del_select()" value="删除所选" style="cursor:hand">
      <input name="id_list" type="hidden" value="">
    </td>
  </tr>
</table>

解决方案 »

  1.   

    //反选是什么意思?<script language="javascript">
    function checkAll(b) {
    var oCheckBox = document.getElementsByName("check");
    var n = oCheckBox.length;
    for (var i=0;i<n;i++) 
    oCheckBox[i].checked=b;
    }
    </script>
    <table width="16%" border="1" style='table-layout:fixed;'>
      <tbody>
        <tr valign="top">
          <td width="24%" height="24" align="center"><input name="check" type="checkbox"  onClick="add_id(1)"></td>
          <td height="24" align="center">&nbsp;</td>
        </tr>
        <tr valign="top">
          <td height="24" align="center"><input name="check" type="checkbox"  onClick="add_id(2)" value="18" ></td>
          <td height="24" align="center">&nbsp;</td>
        </tr>
        <tr valign="top">
          <td height="24" align="center"><input name="check" type="checkbox"  onClick="add_id(3)" value="17" ></td>
          <td height="24" align="center">&nbsp;</td>
        </tr>
      <input name="all_sel" type="hidden" value="26,18,17,16,15,14,">
      <tr>
        <td colspan="2" align="center"><input type="checkbox" name="all_select()" value="checkbox" onClick="checkAll(this.checked)">
          全选
          
          <input type="checkbox" name="un_select" value="checkbox">
          反选 <br>
          <input name="but_del" type="button" onClick="del_select()" value="删除所选" style="cursor:hand">
          <input name="id_list" type="hidden" value="">
        </td>
      </tr>
    </table>
      

  2.   

    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><script>
    function CheckAll(form) {
    for (var i=0;i<form.elements.length;i++) {
    var e = form.elements[i];
    if (e.name != 'chkall' && e.type=='checkbox')
    e.checked = form.chkall.checked;
    //TableBgLock(e);
    }
    }
    </script>
    <body>
    <form name="form1" method="post" action="">  <p>
        <input type="checkbox" name="chkall" value="checkbox" onclick="CheckAll(document.form1)">
      </p>
      <p>&nbsp;</p>
      <p> 
        <input type="checkbox" name="checkbox" value="checkbox">
        <input type="checkbox" name="checkbox2" value="checkbox">
        <input type="checkbox" name="checkbox3" value="checkbox">
        <input type="checkbox" name="checkbox4" value="checkbox">
        <input type="checkbox" name="checkbox5" value="checkbox">
        <input type="checkbox" name="checkbox6" value="checkbox">
        <input type="checkbox" name="checkbox7" value="checkbox">
      </p>
    </form>
    </body>
    </html>绝对能用
      

  3.   

    应该先用了搜索再问问题。:Dhttp://www.baidu.com/s?ie=gb2312&bs=xp+sp2+%D7%B4%CC%AC%C0%B8&sr=&z=&cl=3&f=8&wd=checkbox+%C8%AB%D1%A1&ct=0
      

  4.   

    可以定义一个函数...
    function Check()
    {
    var checkBox=document.getElements;
    for (var i=0,j=1;i<checkBox.length;i++)
    {
     if (typeof checkBox=="checkBox")
     {
      document.getElementById["Check_"+j].checked=true;
    j++
    }
    }
    }<input type="button" id="button1" onClick="Check()"/>
      

  5.   

    function selectAll()
    {
    var allInputs = document.forms[0].tags('INPUT');
    for( var k = 0; k < allInputs.length; k++ )
    {
    if( allInputs[k].type == "checkbox" )
    {
    allInputs[k].checked = true;
    }
    }
    }
      

  6.   

    sorry:
    var checkBox=document.getElements;
    for (var i=0,j=1;i<checkBox.length;i++)换成:
    for(var i=0,j=1;i<document.all.length;i++)
      

  7.   

    <script language="javascript" type="text/javascript">

    function sl()
    {
    var chks = document.getElementsByName("check");

    for (var i=0; i<chks.length ; i++)
    {
    chks[i].checked = (chks[i].checked)?false:true;  
    }
    return true;
    }</script>
    </HEAD><BODY>
    <table width="16%" border="1">
    <tbody>
    <tr valign="top">
    <td width="4%" height="24" align="center"><input name="check" type="checkbox" onClick="add_id(1)" value="26" >1</td>
    <td height="24" align="center">&nbsp;</td>
    </tr>
    <tr valign="top">
    <td height="24" align="center"><input name="check" type="checkbox" onClick="add_id(2)" value="18" >2</td>
    <td height="24" align="center">&nbsp;</td>
    </tr>
    <tr valign="top">
    <td height="24" align="center"><input name="check" type="checkbox" onClick="add_id(3)" value="17" >3</td>
    <td height="24" align="center">&nbsp;</td>
    </tr>
    <input name="all_sel" type="hidden" value="26,18,17,16,15,14,">
    <tr>
    <td colspan="2" align="center"><input type="radio" name="allcheck" value="checkbox" onClick="sl();">全选
    <input type="radio" name="allcheck" value="checkbox" onClick="sl();">
    反选 <br>
    <input name="but_del" type="button" onClick="del_select()" value="删除所选" style="cursor:hand">
    <input name="id_list" type="hidden" value="">
    </td>
    </tr>
    </table>
    </BODY>
    </HTML>