如何判断checkbox是否至少有选择一项
<!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 " />
<title> 无标题文档 </title>
</head>
<SCRIPT language=javascript>
function unselectall()
{
if(document.del.chkAll.checked){
document.del.chkAll.checked = document.del.chkAll.checked&0;
}
}
function CheckAll(form)
{
for (var i=0;i <form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll ")
e.checked = form.chkAll.checked;
}
}
function ConfirmDel()
{
if(confirm( "删除后将无法恢复,您真的要删除么! "))
return true;
else
return false;
}
</SCRIPT>
<body> <form name= "UserReg " method= "post " action= " " onsubmit= "return ConfirmDel(); ">
<p>
1
<input type= "checkbox " name= "checkbox " value= "checkbox " />
</p>
<p>
2
<input type= "checkbox " name= "checkbox2 " value= "checkbox " />
</p>
<p>
3
<input type= "checkbox " name= "checkbox3 " value= "checkbox " />
</p>
<p>
<input name= "chkAll " type= "checkbox " id= "chkAll " onclick= "CheckAll(this.form) " value= "checkbox " />
全选 </p>
<p>
<input type= "submit " name= "Submit " value= "删除 " />
</p>
</form>
</body>
</html>
---------------------------
网上找的部分资料,但不知道怎么用``
____________
我们知道,如果在asp,只要response.write request.form( "checkboxName ")就可以判断是否有选择至少一项,但是必须递交后才可以这样做,那么就要接触脚本语言js,vbs
假设我们有个checkbox叫optHSCameratyp,我们写个函数来判断
function chkCheckBoxChs(objNam){ //检测是否有选择多选框的至少一项
var obj = document.getElementsByName(objNam); //获取多选框数组
var objLen= obj.length; //获取数据长度
var &n