关于(控制表单多选框可供选择的个数)
---恢复内容开始---
1.代码段:
<head>
<meta charset="UTF-8">
<title>控制表单多选框可供选择的个数</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<script language=javascript>
function choosepro(aa){
var checkCount = 3;//最多可以选择3个
var iTemp = 0;
var len = document.getElementsByTagName("input");
if(len.length){
for(var i=0;i<len.length;i++){
if(len[i].checked){
iTemp++;
if(checkCount<iTemp){
alert("您选的商品不能大于"+checkCount+"件!");
aa.checked=false;
return;
}
}
}
}else{
if(len.checked){
iTemp++;
if(checkCount<iTemp){
alert("您选的商品不能大于"+checkCount+"件!");
aa.checked=false;
return;
}
}
}
}
</script>
</head>
<body>
<input type="checkbox" name="toDelGWCProID[1][]" value="1" onClick="choosepro(this)">
<input type="checkbox" name="toDelGWCProID[1][]" value="2" onclick="choosepro(this)">
<input type="checkbox" name="toDelGWCProID[1][]" value="3" onclick="choosepro(this)">
<input type="checkbox" name="toDelGWCProID[1][]" value="4" onclick="choosepro(this)">
<input type="checkbox" name="toDelGWCProID[1][]" value="5" onclick="choosepro(this)">
<input type="checkbox" name="toDelGWCProID[1][]" value="6" onClick="choosepro(this)">
<input type="checkbox" name="toDelGWCProID[1][]" value="7" onclick="choosepro(this)">
<input type="checkbox" name="toDelGWCProID[1][]" value="8" onclick="choosepro(this)">
<input type="checkbox" name="toDelGWCProID[1][]" value="9" onclick="choosepro(this)">
<input type="checkbox" name="toDelGWCProID[1][]" value="10" onclick="choosepro(this)">
</body>
结果:自己看吧