这是我的代码:
但是没有alert出值
<HTML>
<HEAD>
<TITLE>测试订单</TITLE>
<SCRIPT>
function check(){
var isChecked = document.getElementById("isTrue");
for(var a=0;a<isChecked.length;a++){
if(isChecked[a].checked){
var v = isChecked[a].value;
alert(v);
}
}
}
</SCRIPT>
</HEAD>
<BODY>
<form id = "order" name = "order">
<input type = "radio" id = "isTrue" name = "isTrue" value = "1" onclick="check()" />
A
<input type = "radio" id = "isTrue" name = "isTrue" value = "2" onclick="check()" />
B
<input type = "radio" id = "isTrue" name = "isTrue" value = "3" onclick="check()" />
C
<input type = "radio" id = "isTrue" name = "isTrue" value = "4" onclick="check()" />
D
<input type = "radio" id = "isTrue" name = "isTrue" value = "5" onclick="check()" />
E
<input type = "radio" id = "isTrue" name = "isTrue" value = "6" onclick="check()" />
F
<span id = "display" name = "display" style = "font-size:16px; color:red">sdfas</span>
</form>
</BODY>
</HTML>各位高手帮忙一下啊!!!十万火急啊.....

解决方案 »

  1.   

    var isChecked = document.getElementsByName("isTrue");
      

  2.   

    var isChecked = document.getElementsByName("isTrue");
      

  3.   

    <HTML>
    <HEAD>
    <TITLE>测试订单</TITLE>
    <SCRIPT>
    function check(){
    var isChecked = document.getElementsByName("isTrue");
    for(var a=0;a<isChecked.length;a++){
    if(isChecked[a].checked){
    var v = isChecked[a].value;
    alert(v);
    }
    }
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <form id = "order" name = "order">
    <input type = "radio" id = "isTrue" name = "isTrue" value = "1" onclick="check()" />
    A
    <input type = "radio" id = "isTrue" name = "isTrue" value = "2" onclick="check()" />
    B
    <input type = "radio" id = "isTrue" name = "isTrue" value = "3" onclick="check()" />
    C
    <input type = "radio" id = "isTrue" name = "isTrue" value = "4" onclick="check()" />
    D
    <input type = "radio" id = "isTrue" name = "isTrue" value = "5" onclick="check()" />
    E
    <input type = "radio" id = "isTrue" name = "isTrue" value = "6" onclick="check()" />
    F
    <span id = "display" name = "display" style = "font-size:16px; color:red">sdfas</span>
    </form>
    </BODY>
    </HTML>
      

  4.   

    var thisForm=document.order;
    for(var i=0;i<thisForm.isTrue.length;i++)
      {
      if(thisForm.isTrue[i].checked==true)
        {
         var isTrue =thisForm.isTrue[i].value;
         break;
        } 
      }