javascript中radio不是用value取得选中的值
var q1 = document.getElementsByName("q1");
for(var i=0; i<q1.length; ++i)
  if(q1[i].checked)
    alert(q1[i].value)

解决方案 »

  1.   

        if (document.quiz.q1[0].checked){ s+=12;} 
    else {result+="Question 1: " + solution[0] +" <br>"} 换这个方式试试
      

  2.   

    radio不能这样取值function GetRadioValue(name)
    {
      var objs= document.getElementsByName(name);
      for(var i=0;i<objs.length;i++)
      {
         if (objs[i].checked)
            return objs[i].value;
      } 
      return "";
    }
      

  3.   

    哦,知道了,不过就像题目所说的,取到了radio button里所选的值,但是我要判断它是否正确,应该怎么写,是不是应该还是要引用其value,
        var a =document.quiz.q1; 
    for (var k=0;k<a.length;k++)  
        {
        if  (a[k].checked)
    return a[k].value;
    if (a[k].value=="1")
                    { 。}
    像这样取写呢??我试过,不行哦~
      

  4.   

    问题已解决,if (quiz.q1[x].checked)像这样取就可以了,因为我不需要取它的值,只要看看是否有check就可以了,多谢各位!