<script language="javascript">
<!--Edit By Stefli
function chk(){
var obj = document.getElementsByName("stefli");
var objlen = obj.length;
for(var i=0;i<objlen;i++){
if(obj[i].checked==true){
alert("你选择了第"+(i+1)+"个checkbox哦!");
}
}
}
//-->
</script>
<form name="frmstefli">
<input type="checkbox" name="stefli">1
<input type="checkbox" name="stefli">2
<input type="checkbox" name="stefli">3
<input type="checkbox" name="stefli">4
<input type="checkbox" name="stefli">5
<input type="checkbox" name="stefli">6
<input type="button" onClick="chk()" value="检测">
</form>
<!--Edit By Stefli
function chk(){
var obj = document.getElementsByName("stefli");
var objlen = obj.length;
for(var i=0;i<objlen;i++){
if(obj[i].checked==true){
alert("你选择了第"+(i+1)+"个checkbox哦!");
}
}
}
//-->
</script>
<form name="frmstefli">
<input type="checkbox" name="stefli">1
<input type="checkbox" name="stefli">2
<input type="checkbox" name="stefli">3
<input type="checkbox" name="stefli">4
<input type="checkbox" name="stefli">5
<input type="checkbox" name="stefli">6
<input type="button" onClick="chk()" value="检测">
</form>
解决方案 »
- 点击网页空白处触发一个事件
- 高分急求js 脚本 实现 div 隐藏和显示
- 关于导航栏
- 大家新年好,在Javascript中,允许不允许定义的变量或者函数名与DOM的attribute/method一样?
- 方格数显示
- 只用html+javascript能进行权限的控制吗?
- 为什么e.explicitOriginalTarget.id 有时会为空
- 关于设置obj.style.display='none',谢谢
- 如何将一个form中的input框中的值以int类型相加,得到一个总和?
- element-ui select allow-create时如何限制创建的新标签的长度
- 问一个简单的问题
- 高手帮个忙
var thisfrm = document.forms[0];
// 查找Forms里面所有的元素
for (i=0; i<thisfrm.length; i++) {
// 查找模板头中的CheckBox
if (idVal.indexOf ('chkAll') != -1) {
if(chkVal == true) {
thisfrm.elements[i].checked = true;
}
else {
thisfrm.elements[i].checked = false;
}
} // if
// 如果除题头以外的项没有全选上则取消题头的选择 else if (idVal.indexOf ('chkDelete') != -1) {
if(thisfrm.elements[i].checked == false) {
thisfrm.elements[1].checked = false;
} } } // for }
<title>New Page 3</title><script language=javascript>
var str="You have checked the:";
function view(){
for(var i=1;i<5;i++){
var obj=eval("document.all.f1.c"+i);
if (obj.checked==true)
str=str+obj.value+' ';
}
alert(str);
str="You have checked the:";
}
</script>
</head><body>
<form id=f1>
<input type=checkbox id=c1 value=a>a
<input type=checkbox id=c2 value=b>b
<input type=checkbox id=c3 value=c>c
<input type=checkbox id=c4 value=d>d<br>
<input type=button value=view onclick=view()>
</form></body></html>