<form name="form1">
<input type=checkbox name=mm value=a onclick="cc(this)"><br>
<input type=checkbox name=mm value=b onclick="cc(this)"><br>
<input type=checkbox name=mm value=c onclick="cc(this)"><br>
<input type=checkbox name=mm value=d onclick="cc(this)"><br>
<input type=checkbox name=mm value=e onclick="cc(this)"><br>
<input type=checkbox name=mm value=e onclick="cc(this)"><br>
<input type=checkbox name=mm value=e onclick="cc(this)"><br>
<input type=checkbox name=mm value=e onclick="cc(this)"><br>
<input type=checkbox name=mm value=e onclick="cc(this)"><br>
<input type=checkbox name=mm value=e onclick="cc(this)"><br>
<input type=button value=提交 onclick="checkForm()">
</form>
<script>
var n=0;
function cc(obj)
{
if(obj.checked)
n++;
else
n--; if (n > 6)
{
alert("你只能选 6 个");
obj.checked = false;
n--;
return;
}
}
function checkForm()
{
if (n==0){
alert("请选择一项!");
return false;
}
else
document.all("form1").submit();
}
</script>
快给点分来吧
<input type=checkbox name=mm value=a onclick="cc(this)"><br>
<input type=checkbox name=mm value=b onclick="cc(this)"><br>
<input type=checkbox name=mm value=c onclick="cc(this)"><br>
<input type=checkbox name=mm value=d onclick="cc(this)"><br>
<input type=checkbox name=mm value=e onclick="cc(this)"><br>
<input type=checkbox name=mm value=e onclick="cc(this)"><br>
<input type=checkbox name=mm value=e onclick="cc(this)"><br>
<input type=checkbox name=mm value=e onclick="cc(this)"><br>
<input type=checkbox name=mm value=e onclick="cc(this)"><br>
<input type=checkbox name=mm value=e onclick="cc(this)"><br>
<input type=button value=提交 onclick="checkForm()">
</form>
<script>
var n=0;
function cc(obj)
{
if(obj.checked)
n++;
else
n--; if (n > 6)
{
alert("你只能选 6 个");
obj.checked = false;
n--;
return;
}
}
function checkForm()
{
if (n==0){
alert("请选择一项!");
return false;
}
else
document.all("form1").submit();
}
</script>
快给点分来吧
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货