全选和反选的按钮代码,代码如下
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>cyberobject.com - checkbox seclet or disselect all</title>
<script language="JavaScript">
<!--
function checkboxselect(itemname,checkstatus) {
if(!itemname) return;
if(!itemname.length) {
itemname.checked=checkstatus;
} else {
for(var i=0;i<itemname.length;i++) {
itemname[i].checked=checkstatus;
}
}
}
//-->
</script>
</head>
<body>
<form name="form1" method="post" action="">
<p>
<input type="checkbox" name="zone_checkbox" value="zone_checkbox" onClick="checkboxselect(document.form1.checkbox, document.form1.zone_checkbox.checked)">全选
</p>
<p>
<input type="checkbox" name="checkbox" id="checkbox" value="1">1 <br>
<input name="checkbox" type="checkbox" id="checkbox" value="2">2 <br>
<input name="checkbox" type="checkbox" id="checkbox" value="3">3 <br>
<input name="checkbox" type="checkbox" id="checkbox" value="4">4 <br>
<input name="checkbox" type="checkbox" id="checkbox" value="5">5 <br>
<input name="checkbox" type="checkbox" id="checkbox" value="6">6
</p>
<p>
<input type="submit" name="Submit" value="清除">
</p>
</form>
</body>
</html>