troubleshooting Question

Multiple Radio Buttons Check

Avatar of rgarimella
rgarimella asked on
JavaScript
7 Comments1 Solution614 ViewsLast Modified:
Hi Folks,

I have a series of radio button group with yes/no options.

I want to evaluate it to an array of correct answers, how do I do it?

var correctanswers = [1,0,1,0];

Where 1 is true or Yes is selected and 0 is false or No is selected

This has to be dynamic as sometimes there will be more than 4

Basically I want to match the arrays, if it is a correct match or not

Any help is appreciated
Thanks

RG
<form name="mcForm" method="post"> 
  <table width="300" border="0" cellspacing="0" cellpadding="4">
      <tr>
          <td width="26" valign="top" id="radio1"> <input type="radio" name="radiobutton1" value="yes" accesskey="A"  id="yes"></td>
          <td width="18" valign="top" id="radio1"><input type="radio" name="radiobutton1" value="no" accesskey="B"  id="no"></td>
          <td width="556" valign="top" id="Text1"><font size="2" face="Arial, Helvetica, sans-serif"><label for="1">They compare different  strategies</label></font></td>
      </tr>
      <tr>
          <td width="26" valign="top" id="radio2"> <input type="radio" name="radiobutton2" value="yes" accesskey="C"  id="yes"></td>
          <td width="18" valign="top" id="radio2"><input type="radio" name="radiobutton2" value="no" accesskey="D"  id="no"></td>
          <td width="556" valign="top" id="Text2"><font size="2" face="Arial, Helvetica, sans-serif"><label for="2">They provide performance-based incentives
    </label></font></td>
	</tr>
      <tr>
          <td width="26" valign="top" id="radio3"> <input type="radio" name="radiobutton3" value="yes" accesskey="E"  id="yes"></td>
          <td width="18" valign="top" id="radio3"><input type="radio" name="radiobutton3" value="no" accesskey="F"  id="no"></td>
          <td width="556" valign="top" id="Text3"><font size="2" face="Arial, Helvetica, sans-serif"><label for="3">They provide data 
    </label></font></td>
	</tr>
      <tr>
          <td width="26" valign="top" id="radio4"> <input type="radio" name="radiobutton" value="yes" accesskey="G"  id="yes"></td>
          <td width="18" valign="top" id="radio4"><input type="radio" name="radiobutton" value="no" accesskey="H"  id="no"></td>
          <td width="556" valign="top" id="Text4"><font size="2" face="Arial, Helvetica, sans-serif"><label for="4">They demonstrate the benefits 
    </label></font></td>
</tr>
 
      <tr> 
        <td>&nbsp;</td>
        <td></td>
        <td> <div align="left"> 
            <input type="button" value="Check Answer" onClick="checkAnswer(form)">
        </div></td>
      </tr>	
  </table>
</form>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros