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);
{
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>