var countChk = 0;
var chk = document.all.m_type;
for(var i=0; i<chk.length; i++)
if(chk[i].checked)countChk++;alert(countChk);
var chk = document.all.m_type;
for(var i=0; i<chk.length; i++)
if(chk[i].checked)countChk++;alert(countChk);
解决方案 »
- 怎么去选择一种好的js框架??各位讨论下
- 求达人 帮忙解决正则表达式的问题【急】在线等
- 怎么让图片加载完后再执行JS
- [急]电子商务网站,填写送货地址时,选择之前填写的地址,但是依然提示需要填写地址号码等几项,谢谢
- 请问如果是非ie的浏览器,怎么去读xml的文件啊
- 有关<input type="hidden">的问题
- 我在做一棵树,现在遇到了一个大问题,我怎么能够知道我的一个父节点有多少个子节点?急!!!!!
- 救急!!请大家帮帮我,关于图片滚动
- 请教如何用javascript程序,当点击checkbox(客户端控件)时,判断其为checkbox.
- 自动分页怎么加边框
- 打开窗口的问题
- 读取文件内容(JS市斤进,在线等)
{
var i=0;
for(var k=0;k<document.form1.tbl.length;k++)
{
if(document.form1.tbl[k].checked)
{
i++;
var s=form1.tbl[k].value;
if(form1.all[s].value==""){
alert("您要添加的表"+s+"的描述不能为空");
i=-1;
break;
}
}
}
if(document.form1.tbl.checked)
{
i++;
var s=form1.tbl.value;
if(form1.all[s].value==""){
alert("您要添加的表"+s+"的描述不能为空");
i=-1;
}
} if(i>0){
if(window.confirm("您确认要添加的信息吗?"))
{
document.form1.submit();
}
}
else if(i==0)
{
alert("请至少选择一个表名");
}
return false;
}
function d_check()
{var obj,count;
obj=document.getElementsByName("m_type");
count=0;
for(i=0;i<obj.length;i++)
{
if (obj[i].checked== true) {count++};
}
if (count<1)
{
alert("至少选择一个!");
return false;
}
if (count<2)
{
alert("最多只能选两个!");
return false;
}
return true;
}
<input type=checkbox>1
<input type=checkbox>1
<input type=checkbox>1
<br>
<input type="button" value="全选" onclick="doCheckBox(1)">
<input type="button" value="全不选" onclick="doCheckBox(2)">
<input type="button" value="反选" onclick="doCheckBox(3)">
<script>
function doCheckBox(iType)
{
//1:全选;2:全不选;3:反选;
for(iIndex=0;iIndex<document.all.length;iIndex++)
{
if(document.all(iIndex).type=="checkbox")
{
switch(iType)
{
case 1:document.all(iIndex).checked=true;break;
case 2:document.all(iIndex).checked=false;break;
case 3:{if(document.all(iIndex).checked==true){document.all(iIndex).checked=false;}else{document.all(iIndex).checked=true;}}break;
}
}
}
}
</script>