Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts,

Am doing a small application called Online Test
In this am getting the random questions from code behind (By ajax call) and storing it in the java script array.

Now am displaying the questions one by one in my web page by this code.
C#
var questionToDisplay = questionArr[index];
             document.getElementById("spnQuestion").innerHTML=questionToDisplay.Question;
document.getElementById("spnOptionA").innerHTML = questionToDisplay.OptionA;
document.getElementById("spnOptionB").innerHTML = questionToDisplay.OptionB;
document.getElementById("spnOptionC").innerHTML = questionToDisplay.OptionC;
document.getElementById("spnOptionD").innerHTML = questionToDisplay.OptionD;


But it is not showing in a correct way. Here am able to select all the radio buttons.
and my html design is
JavaScript
<div class="row">
    <span id="spnQuestion"></span>
</div>
<div class="row">
  <input type="radio" id="rdbOptionA" /><span id="spnOptionA"></span>
</div>
<div class="row">
  <input type="radio" id="rdbOptionB" /><span id="spnOptionB"></span>
</div>
<div class="row">
 <input type="radio" id="rdbOptionC" /><span id="spnOptionC"></span>
</div>
<div class="row">
 <input type="radio" id="rdbOptionD" /><span id="spnOptionD"></span>
</div>

can any one please tell me a correct way to display these options.

thanks in advance
(Keerthi Kumar)
Posted
Updated 22-Apr-15 21:48pm
v2

1 solution

Related radio buttons must have a common name attribute to identify them as a group, and use the value attribute to assign different value to each radio button in the group. see example:
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_radio[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900