js获取radio选中索引值

<form name="form1" onsubmit="return foo()">
<input type="radio" name="radiogroup1">
<input type="radio" name="radiogroup1">
<input type="radio" name="radiogroup1">
<input type="radio" name="radiogroup1">
<input type="radio" name="radiogroup1">
<input type="radio" name="radiogroup1">
<input type="submit">
</form>
<script>
function foo(){
    for(i=0;i<document.form1.radiogroup1.length;i++)
    {
       if (document.form1.radiogroup1[i].checked){
    alert(i);
    return i;
  }
    }
 return false;
}
</script>

上一篇:js获取select选中的标签option的值


下一篇:jquery获取文本框的内容