<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<input type="checkbox" id="check_box" />张三<br />
<input type="checkbox" />李四<br />
<input type="checkbox" />王五<br />
<div>
<label for="check_box">全选/取消</label>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<input type="checkbox" id="check_box" />张三<br />
<input type="checkbox" />李四<br />
<input type="checkbox" />王五<br />
<div>
<label for="check_box">全选/取消</label>
</div>
</body>
</html>
<form name='form1'>
<input type='checkbox' name='seleall'>
<input type='checkbox' name='listcheck[]'>
<input type='checkbox' name='listcheck[]'>
</form>
<script language="Javascript"> function checkall(form)
{
for (var i=0;i<form.elements.length;i++)
{
var obj=form.elements[i];
var objname=obj.name;
if (objname.substring(0,4)=="list") { obj.checked=form.seleall.checked }
}
}
</script>
<html>
<body>
<form name="form1" >
<input type="checkbox" name="seleall" onclick="checkall(this.form)">
<input type="checkbox" name="listcheck[]">
<input type="checkbox" name="listcheck[]">
</form>
</body>
</html>
<script language="Javascript"> function checkall(form)
{
for (var i=0;i<form.elements.length;i++)
{
var obj=form.elements[i];
var objname=obj.name;
if (objname.substring(0,4)=="list") { obj.checked=form.seleall.checked }
}
}
</script>
<script>
$(function(){
$('#checkAll').click(function(){
$("input[name='userName[]']").each(function(){
if($(this).attr("checked")){
$(this).attr("checked",false);
}else{
$(this).attr("checked",true);
}
});
});
})
</script>
<body>
<form id="del" name="del" action="">
<input type="checkbox" name="checkAll" id="checkAll" />选择<br />
<input name="userName[]" type="checkbox" id="a" value="1" />张三<br />
<input name="userName[]" type="checkbox" id="b" value="2" />李四<br />
<input name="userName[]" type="checkbox" id="c" value="3"/>王五<br />
<input type="button" name="del" value="批量删除" />
</form>
</body>
使用js特别是jQuery框架可以很方便地实现,上面几位已经给出答案了。
++