表单是
<form name="formId">
<input type="checkbox" name="selectField" value=1>
<input type="checkbox" name="selectField" value=2>
</form>
function getCheckCount(){
var checkcount = 0;
var len = document.formId.selectField.length;
alert(len)
for (var i = 0; i < len; i++)
{
if (document.formId.selectField[i].checked==true)
{
checkcount = checkcount + 1;
}
}
return checkcount;
}
<form name="formId">
<input type="checkbox" name="selectField" value=1>
<input type="checkbox" name="selectField" value=2>
</form>
function getCheckCount(){
var checkcount = 0;
var len = document.formId.selectField.length;
alert(len)
for (var i = 0; i < len; i++)
{
if (document.formId.selectField[i].checked==true)
{
checkcount = checkcount + 1;
}
}
return checkcount;
}