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.
var questionToDisplay = questionArr[index];
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
<div class="row">
    <span id="spnQuestion"></span>
<div class="row">
  <input type="radio" id="rdbOptionA" /><span id="spnOptionA"></span>
<div class="row">
  <input type="radio" id="rdbOptionB" /><span id="spnOptionB"></span>
<div class="row">
 <input type="radio" id="rdbOptionC" /><span id="spnOptionC"></span>
<div class="row">
 <input type="radio" id="rdbOptionD" /><span id="spnOptionD"></span>

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

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

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:[^]
Share this answer

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