我创建了一个测验,我希望每页显示一个问题,下面给出了我对 _ans 的部分视图,因为当我检查单选按钮时,下一个链接是有效的。如果我希望帮助获取单选按钮的值我检查了,如果我没有检查它返回null
<div id = "main1">
<% form_for @answer do |f|%>
<div class = "questions">
<div id = "passage">
<%= "Passage"%>:<br>
<%#= @ans.passage %>
</div> <br>
<label>
<%= @s %> . <%= @ans.ques %>
</label>
<div id = "options">
<label for "options">
<div id = "option-1">
<%= radio_button_tag 'ans', 'ans1'%><%= @ans.ans1 %>
</div><br>
<div id = "option-2">
<%= radio_button_tag 'ans', 'ans2'%><%= @ans.ans2 %>
</div><br>
<div id = "option-3">
<%= radio_button_tag 'ans', 'ans3'%><%= @ans.ans3 %>
</div><br>
<div id = "option-4">
<%= radio_button_tag 'ans', 'ans4'%><%= @ans.ans4 %>
</div><br>
</label>
</div><br>
</div><br><br>
<div id = "prev">
<%= link_to_remote "Previous",
:before => "Element.show('loader')",
:success => "Element.hide('loader')",
:update => "answers",
:url=>{:controller=>"answers", :action=>"previous"},
:with => "'&passed_question=#{@ans.id-1}&'+'&exam_group_id=#{@exam_group.id}&'"
%>
</div>
<div id = "next">
<%= link_to_remote "Previous",
:before => "Element.show('loader')",
:success => "Element.hide('loader')",
:update => "answers",
:url=>{:controller=>"answers", :action=>"previous"},
:with => "'answer=$$('[name*=ans]:checked)[0].value+'&passed_question=#{@ans.id-1}&'+'&exam_group_id=#{@exam_group.id}&'"
%>
</div>
<div id = "sub">
<%= link_to "Submit", final_exam_group_answers_path(@exam_group)%>
</div>
<% end %>
</div>