<html> <head> <title>test</title> <script language="javascript"> function ReSel(){ for(i=0;i<document.form1.logs.length;i++){ //这一用法只对form表单有效 document.form1.logs[i].checked = true; //如果是实现【全不选】的话,改成false即可 } } function SeSel(){ for(i=0;i<document.form1.logs.length;i++){ if(document.form1.logs[i].checked) document.form1.logs[i].checked = false; else document.form1.logs[i].checked = true; } } function DelSel(){ var nid = getCheckboxItem(); if(nid==""){ alert("请选择项目! "); return ; } location.href = "member_activation.php?dopost=del&ids="+nid; } //获得选中文件的文件名 function getCheckboxItem(){ var allSel=""; if(document.form1.logs.value) return document.form1.logs.value; for(i=0;i<document.form1.logs.length;i++) { if(document.form1.logs[i].checked){ if(allSel=="") allSel=document.form1.logs[i].value; else allSel=allSel+"-"+document.form1.logs[i].value; } } return allSel; } </script> </head> <body> <table> <tr> <td>列表</td> </tr> <tr> <td>选择</td> <td>id</td> <td>名字</td> </tr> <form name="form1"> {foreach name="list" key='key' item='val'} <tr> <td><input name='logs' type='checkbox' value='{$val.id/}' /></td> <td>{$val.id}</td> <td>{$val.name}</td> </tr> {/foreach} </form> <tr bgcolor="#ffffff"> <td height="36" colspan="9"> <a class="coolbg" onClick="ReSel();" >全选</a> <a class="coolbg" onClick="SeSel();" >反选</a> <a class="coolbg" onClick="DelSel();">删除</a> </td> </tr> </table> </body> </html>