名称:checkboxselect
功能:将指定的多选框全选或全不选
参数:itemname,表单项的对像引用
checkstatus,是否选中True或False
返回:无,直接选中多选框或全不选中
说明:itemname示例:document.form1.checkboxname
*************************************************************/
function checkboxselect(itemname,checkstatus) {
if(!itemname) return;
if(!itemname.length) {
itemname.checked=checkstatus;
} else {
for(var i=0;i itemname[i].checked=checkstatus;
}
}
}
示例:
a.htm
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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 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="checkboxdo.asp">
<p>
<input type="checkbox" name="checkbox2" value="checkbox" onClick="checkboxselect(document.form1.checkbox, document.form1.checkbox2.checked)">
全选
</p>
<p> <input type="checkbox" name="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>
b.asp
<%
yourarray = Request.form("checkbox")
yourarrays = split(yourarray,",")
'response.write UBound(yourarrays)+1
for i=0 to UBound(yourarrays)
response.write yourarrays(i) & "<br>"
next
%>
Trackback: http://tb.donews.net/TrackBack.aspx?PostId=59317