<script>
function check(obj)
{
var j=0;
var el = f1.elements;
var count = el.length;
var obj=event.srcElement;
for (i=0;i<count;i++)
{
if (el[i].type=="checkbox" && el[i].checked==true)
j++;
}
if(j>5)
{
alert("最多只能選取5個");
obj.checked=false;
}
}
</script>
<form name="f1" action="" method="post" onclick="check(this)">
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
</form>
function check(obj)
{
var j=0;
var el = f1.elements;
var count = el.length;
var obj=event.srcElement;
for (i=0;i<count;i++)
{
if (el[i].type=="checkbox" && el[i].checked==true)
j++;
}
if(j>5)
{
alert("最多只能選取5個");
obj.checked=false;
}
}
</script>
<form name="f1" action="" method="post" onclick="check(this)">
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
</form>
解决方案 »
- flexpaper跨域调用网络swf文件问题
- 一段字符滚动出现的代码,看不大懂,谁能帮忙注释一下
- 求救,select另类的隐藏问题,急!!!
- 谁知道标尺功能怎么实现?就像很多设计软件中的上部和左边的那种标迟功能?
- 关于ie快捷按钮的使用问题,急急急!!!
- 如何在校验控件数据后,使该控件得到焦点。
- 父窗口的控件怎样获得子窗口的事件触发的值(多个值)?
- 听过使用IE的一个工具,就可以把一个delphi编译的exe变成可以在浏览器中运行的程序,有谁知道?
- 弹出警告框,可以改变字体颜色和大小怎么实现
- 关于list转换成json的问题 想知道下面这种json串怎么转换成 求高人
- 请教:请问如何比较俩个字符串是否相等?急急
- IE中能响应window.event.keyCode事件,而在mozilla却不能,怎么解决?急!!!
<script>
function check(obj)
{
var j=0;
var el = f1.elements;
var count = el.length;
var obj=event.srcElement;
for (i=0;i<count;i++)
{
if (el[i].type=="checkbox" && el[i].checked==true)
j++;
}
if(j>2)
{
alert("最多只能選取2個");
obj.checked=false;
}
}
</script>
<form name="f1" action="" method="post" onclick="check(this)">
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
<input type="checkbox" >
</form>