/**
* This function is to get the number of the checked checkboxes.
* JK 2003-12-08
*/
function getCheckedCheckboxesNum(nameOfCheckBox)
{
var theNum=0;
var theCheckboxInputs=document.getElementsByName(nameOfCheckBox);
for (var i=0;i<theCheckboxInputs.length;i++)
{
if(theCheckboxInputs[i].checked) theNum++;
}
return theNum;
}
* This function is to get the number of the checked checkboxes.
* JK 2003-12-08
*/
function getCheckedCheckboxesNum(nameOfCheckBox)
{
var theNum=0;
var theCheckboxInputs=document.getElementsByName(nameOfCheckBox);
for (var i=0;i<theCheckboxInputs.length;i++)
{
if(theCheckboxInputs[i].checked) theNum++;
}
return theNum;
}
<input type=checkbox name=ch1>
<input type=checkbox name=ch2>
<input type=checkbox name=ch3>
<p></p>
<input type=button value=check onclick=abc()>
<script language="javascript">
<!--
function abc()
{
var aaa;
var bb;
for(var i=0;i<4;i++)
{
aaa=eval("ch"+i);
if(aaa.checked)
bb=1;
}
if (bb!=1)
alert("请选择一个");
}
//-->
</script>