!!!!控制checkbox的選擇????? 定义一个计数变量,自己想想,不行我再给你代码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script>function check(obj){ var j=0; var el = f1.elements; var count = el.length; for (i=0;i<count;i++) { if (el[i].type=="checkbox" && el[i].checked==true) j++; } if(j>8) { alert("最多只能選取8個"); obj.checked=false; }}</script><form name="f1" action="" method="post"> <input type="checkbox" onclick="check(this)"> <input type="checkbox" onclick="check(this)"> <input type="checkbox" onclick="check(this)"> <input type="checkbox" onclick="check(this)"> <input type="checkbox" onclick="check(this)"> <input type="checkbox" onclick="check(this)"> <input type="checkbox" onclick="check(this)"> <input type="checkbox" onclick="check(this)"> <input type="checkbox" onclick="check(this)"></form> 获取文件名 难道没有真正的页面全频显示的方法吗?? 这么获得书名号里的东西,怎么写正则表达式啊?具体代码 怎麼讓js在繁體也可以用啊? 缺少对象错误,可我怎么也找不到,请论坛的xdjm帮忙? function调用的问题 蛙蛙请教:如何把一个xml转换成vml图形呀 请教:用javascript有没有可能屏蔽掉整个页面的所有键盘和鼠标输入? 用JQ做弹出窗口,进行数据库操作后如何关闭刷新原来页面 wdatepicker控件求助 ■■■超难问题:如何屏蔽弹出窗口的关闭按钮?■■■ 菜鸟求教啊
function check(obj)
{
var j=0;
var el = f1.elements;
var count = el.length;
for (i=0;i<count;i++)
{
if (el[i].type=="checkbox" && el[i].checked==true)
j++;
}
if(j>8)
{
alert("最多只能選取8個");
obj.checked=false;
}
}
</script>
<form name="f1" action="" method="post">
<input type="checkbox" onclick="check(this)">
<input type="checkbox" onclick="check(this)">
<input type="checkbox" onclick="check(this)">
<input type="checkbox" onclick="check(this)">
<input type="checkbox" onclick="check(this)">
<input type="checkbox" onclick="check(this)">
<input type="checkbox" onclick="check(this)">
<input type="checkbox" onclick="check(this)">
<input type="checkbox" onclick="check(this)">
</form>