XML : trying to get check if radio forms have been checked an issue and alert in case they havn't

i'm triying to get the data on the user's selection on a radio form and i've been trying to do it like this:

  <form id="office">      <label id="ques1"> question 1</label>          <div class="q1 wrong q1a1"><input type="radio" name="question1" value="q1a1" /> Answer1 <br/></div>          <div class="q1 wrong q1a2"><input type="radio" name="question1" value="q1a2" /> Answer2 <br/></div>          <div class="q1 wrong q1a3"><input type="radio" name="question1" value="q1a3" /> Answer3 <br/></div>          <div class="q1 right q1a4"><input type="radio" name="question1" value="q1a4" /> Answer4 <br/></div>                <br/>  <input type="submit" name="submitAnswers" value="Submit Your Answers" onclick="checkFunction()" />  </form>  <script>  var answersQ01 = document.getElementsById(q1a1).value;    function checkFunction()  {  if (answersQ01.checked) {/*here i would like to know if it's checked or not*/}    };    

which isn't seem to be working. any ideas on how to approuch it? i would rather, if possible, ansewrs in HTML and JavaScript as i don't know PHP or jQuery.

thanks a lot!

P.S I've put each input in a div, so that i can give them seperate designs in CSS.

No comments:

Post a Comment