Hello
I am trying to achieve the following - from a list of questions each with 4 multiple choice answers I need to show whether the user has answered correctly (immediately) by showing whether it was correct or incorrect once a radio button has been pressed.
Here is an example of a question:
<ol>
<li id="question_one">
<p><input type="radio" name="question_1" value="answer_1" />Corn</p>
<p><input type="radio" name="question_1" value="answer_2" />Cotton</p>
<p><input type="radio" name="question_1" value="answer_3" />Rice</p>
<p><input type="radio" name="question_1" value="answer_4" />Soybeans</p>
</li>
</ol>
<div id="q1_answer_1" class="show_answer">Corn 11.0%</div>
<div id="q1_answer_2" class="show_answer">Cotton 2.5%</div>
<div id="q1_answer_3" class="show_answer">Rice 11.0%</div>
<div id="q1_answer_4" class="show_answer">Soybeans 7.0%</div>
And the resulting jquery:
$("#question_one input:radio:eq(answer_1)").click(function(){
$("#q1_answer_1").show(100);
});
$("#question_one input:radio:eq(answer_2)").click(function(){
$("#q1_answer_2").show(100);
});
$("#question_one input:radio:eq(answer_3)").click(function(){
$("#q1_answer_3").show(100);
});
$("#question_one input:radio:eq(answer_4)").click(function(){
$("#q1_answer_4").show(100);
});
I believe this won't work because eq()
will only work for numeric values? Is there an equivalent of eq()
that will work for input values? Or any other suggestions as to how the above might work?
Many thanks