var a = document.getElementsByTagName("input");
for (var i=0; i<a.length; i++)
{
if (a[i].type == "checkbox" && a[i].checked)
alert("你已经选择了第 "+ (i+1) +" 个checkbox");
}
for (var i=0; i<a.length; i++)
{
if (a[i].type == "checkbox" && a[i].checked)
alert("你已经选择了第 "+ (i+1) +" 个checkbox");
}
<p><input type="radio" value="value2" name="R1">value2</p>
<p><input type="radio" value="value3" name="R1">value3</p>
<p><input type="radio" value="value4" name="R1" checked>value4</p>
<p><input type="button" value="按钮" name="B1" ></p>
</form><script>
function frm.B1.onclick(){
for(t=0;t<frm.R1.length;t++){
if(frm.R1[t].checked==true)
alert("值为:"+frm.R1[t].value)
}}</script>
测试通过
for(i=0;i<objChkbox.length;i++)
{
if(objChkbox[i].checked) //如果该chkbox被选中了
alert(i);
}