<script language="javascript">
function checkValue(){
var chk = document.all.mychk;
for( i =0 ; i< mychk.length ; i++){
if(mychk[i].checked == true){
alert(mychk[i].value);
}
}}
</script>
<input type="checkbox" value="1" name="mychk">
<input type="checkbox" value="2" name="mychk">
<input type="checkbox" value="3" name="mychk">
<input type="checkbox" value="4" name="mychk">
<input type="checkbox" value="5" name="mychk">
<input type="checkbox" value="6" name="mychk">
<input type="checkbox" value="7" name="mychk">
<input type="checkbox" value="8" name="mychk">
<button onclick="checkValue()">
function checkValue(){
var chk = document.all.mychk;
for( i =0 ; i< mychk.length ; i++){
if(mychk[i].checked == true){
alert(mychk[i].value);
}
}}
</script>
<input type="checkbox" value="1" name="mychk">
<input type="checkbox" value="2" name="mychk">
<input type="checkbox" value="3" name="mychk">
<input type="checkbox" value="4" name="mychk">
<input type="checkbox" value="5" name="mychk">
<input type="checkbox" value="6" name="mychk">
<input type="checkbox" value="7" name="mychk">
<input type="checkbox" value="8" name="mychk">
<button onclick="checkValue()">
解决方案 »
- div 里面调用 JS 的ID,出现问题。document.getElementById('abc')为空或不是对象
- ExtJs的desktop程序开发中怎么使用MVC模式啊!
- 有关js锁定页面急~~~~~~~~~~~~!
- jsp中关于HTTP Status 500这样的错误何解?
- 求助,JavaScript的加密算法
- 怎么样用windows.open()方法弹出窗体的标题颜色改变?
- 如何取得页面中所有元素最大的zIndex值?
- 如果想在框架里面传个值出来要怎么做呢?
- 静态页面如何得到当前时间
- 关于ajaxFileUpload中dataType的问题
- 在javascript中怎么样才能打开一个文件(已知路径)
- 怎样实现在html网页上点击doc附件时弹出另存为对话框而不被直接打开
function check(){
var theobj=document.all.tags("INPUT")
var thechecked=new Array()
var j=0;
for(i=0;i<theobj.length;i++)
if(theobj[i].type=="checkbox"&&theobj[i].checked==true)
thechecked[j++]=theobj[i].value
alert(thechecked)
}
</script>
<input type=checkbox value=1>1
<input type=checkbox value=2>2
<input type=checkbox value=3>3
<input type=checkbox value=4>4
<input type=checkbox value=5>5
<input type=button value=Check onclick=check()>