写一个题库系统,学生填写完答案后,老师再后台查看学生写的答案

学生的答案,存到了库里,通过request在js中取出,试卷格式ABCD是通过迭代写的,这时候需要将学生的答案,对应到试卷ABCD上,单选默认选中,js取值,默认选中,只有最后一个管用,其他都不管用为什么?

    function test(){
            var optionCheck = "<%=request.getAttribute("answerCheck") %>";
            var optionCheckArr=new Array();
            optionCheckArr = optionCheck.split("-");
            var option=new Array();
            for(var i=0;i<optionCheckArr.length;i++){
                        var k=0;
                        if(optionCheckArr[i]=="A"){
                            k=0;
                            debugger;
                            $('input:radio').eq(k).attr('checked', 'true');
                            alert("0000");
                        }else if(optionCheckArr[i]=="B"){
                            k=1;
                            debugger;
                            $('input:radio').eq(k).attr('checked', 'true');
                            alert("1111");
                        }else if(optionCheckArr[i]=="C"){
                            k=2;
                            debugger;
                            $('input:radio').eq(k).attr('checked', 'true');
                            alert("2222");
                        }else if(optionCheckArr[i]=="D"){
                            k=3;
                            debugger;
                            $('input:radio').eq(k).attr('checked', 'true');
                            alert("3333");
                        }

                     //$('input:radio').slice(1,2).attr('checked', 'true');
                    }

            //} 
        }

jsp中迭代,是通过

<c:iterator value="#dd.option" var="ddd" status="sttt">
                        <div class="am-radio">
                          <label>
                              <input type="radio" name="dx${dd.exerciseContentId}" id="dx${dd.exerciseContentId}" value="${ddd.id }">${ddd.name }

                          </label>
                          </div>
                        </c:iterator>

求大神指点

你写的js代码有问题,不知道你的optionCheckArr是什么东西,为什么需要遍历

你的意思是有很多题目吗?然后给选中的时候只有最后一个选中了?应该是因为你的input:radio对象取的有点问题