title: How can i get the values out of multiple html form elements?
body: <p>I made a test and I'm trying to get the values associated with each answer so i can give the user a score based on those values.  Right now the code gives me double the answers worth.  Right now there are 7 questions and each time the user clicks the radio button with the right answer it should be worth 1 point. At the end when I submit test it seems as if all the values were doubled(getting a 200% when i only got 100%).  Any help is appreciated.</p>
  
  <p>Here is my test:</p>
  
  <pre><code>&lt;ol&gt;
  &lt;li&gt;What are the three main areas of the Standard User Interface?
    &lt;ul type="none"&gt;
      &lt;li&gt;&lt;input type="radio" name="q1" value="0"  /&gt;Header, Banner, Frame, Application Window&lt;/li&gt;
      &lt;li&gt;&lt;input type="radio" name="q1" value="0"  /&gt; Content Frame, Homepage, Form &lt;/li&gt;
      &lt;li&gt;&lt;input type="radio" name="q1" value="1" onchange="checkAnswer()"/&gt; Application Navigator, Banner Frame, Content Frame &lt;/li&gt;
      &lt;li&gt;&lt;input type="radio" name="q1" value="0"  /&gt; Larry, Moe, and Curly&lt;/li&gt;
    &lt;/ul&gt;
   &lt;/li&gt;
  
  &lt;li&gt;In the User interface, what is the gray toolbar called which allows you to add bookmarks?
  
    &lt;ul type="none"&gt;
      &lt;li&gt;&lt;input type="radio" name="q2" value="0" /&gt; Gauge&lt;/li&gt;
      &lt;li&gt;&lt;input type="radio" name="q2" value="1" onchange="checkAnswer()"/&gt; Edge&lt;/li&gt;
      &lt;li&gt;&lt;input type="radio" name="q2" value="0" /&gt; Remedy&lt;/li&gt;
      &lt;li&gt;&lt;input type="radio" name="q2" value="0" /&gt; Banner&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  
  &lt;li&gt;What can be captured in an update set?
  
     &lt;ul type="none"&gt;
       &lt;li&gt;&lt;input type="radio" name="q3" value="0" /&gt; Modified CI Rules&lt;/li&gt;
       &lt;li&gt;&lt;input type="radio" name="q3" value="1" onchange="checkAnswer()"/&gt; Business Rules&lt;/li&gt;
      &lt;li&gt;&lt;input type="radio" name="q3" value="0" /&gt; Scheduled Jobs&lt;/li&gt;
      &lt;li&gt;&lt;input type="radio" name="q3" value="0" /&gt; None of these&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  
   &lt;li&gt;What should you always do before you commit an update set?
  
     &lt;ul type="none"&gt;
       &lt;li&gt;&lt;input type="radio" name="q4" value="1" onchange="checkAnswer()" /&gt; Preview&lt;/li&gt;
      &lt;li&gt;&lt;input type="radio" name="q4" value="0"  /&gt; Merge&lt;/li&gt;
      &lt;li&gt;&lt;input type="radio" name="q4" value="0"  /&gt; Ignore&lt;/li&gt;
      &lt;li&gt;&lt;input type="radio" name="q4" value="0"  /&gt; All of these&lt;/li&gt;
     &lt;/ul&gt;
   &lt;/li&gt;
  
   &lt;li&gt;Which of the following is a Business Rule best pratice?
  
     &lt;ul type="none"&gt;
      &lt;li&gt;&lt;input type="radio" name="q5" value="1" onchange="checkAnswer()" /&gt; Make business rules small and specific&lt;/li&gt;
  
       &lt;li&gt;&lt;input type="radio" name="q5" value="0"  /&gt; Use of conditions is not necessary&lt;/li&gt;
  &lt;li&gt;&lt;input type="radio" name="q5" value="0"  /&gt; Global business rules should be used&lt;/li&gt;
  
      &lt;li&gt;&lt;input type="radio" name="q5" value="0"  /&gt; None of these&lt;/li&gt;
    &lt;/ul&gt;
   &lt;/li&gt;
  
   &lt;li&gt;Which of the following is a Client Script best practice?
  
     &lt;ul type="none"&gt;
      &lt;li&gt;&lt;input type="radio" name="q6" value="0"  /&gt; Use hard coded data&lt;/li&gt;
   &lt;li&gt;&lt;input type="radio" name="q6" value="0"  /&gt; Maximize server lookup&lt;/li&gt;
   &lt;li&gt;&lt;input type="radio" name="q6" value="1" onchange="checkAnswer()" /&gt; Do not use g_form.getReference()&lt;/li&gt;
  &lt;li&gt;&lt;input type="radio" name="q6" value="0"  /&gt; All of these&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  
  &lt;li&gt;Which of the following are debugging features?
  
   &lt;ul type="none"&gt;
   &lt;li&gt;&lt;input type="radio" name="q7" value="0"  /&gt; Debug Business Rule&lt;/li&gt;
       &lt;li&gt;&lt;input type="radio" name="q7" value="0"  /&gt; Javascript&lt;/li
       &lt;li&gt;&lt;input type="radio" name="q7" value="1" onchange="checkAnswer()" /&gt; Debug Business Rule and Javascript&lt;/li&gt;
       &lt;li&gt;&lt;input type="radio" name="q7" value="0"  /&gt; There is none&lt;/li&gt;
  
        &lt;/ul&gt;
  &lt;/li&gt;
  
  
  &lt;/ol&gt;
  
  
  
  
  &lt;button onclick="finishTest()"&gt; Submit Test  &lt;/button&gt;
  </code></pre>
  
  <p>Here is my javascript:</p>
  
  <pre><code>var question=document.getElementsByTagName("input");
  var grade;
  var score = 0;
  var totalQuestions = 7;
  function checkAnswer(){
      for(var questionNum = 0; questionNum&lt;totalQuestions; questionNum++){
          var answer = question[questionNum].value;
          if(answer=="1"){
              score+=1;
  
          }else{
              score+=0;
          }
  
          grade = "%" + (score/totalQuestions)*100;
      }
  }
  function finishTest(){
  
      alert(" You scored a " +grade);
  
  }
  </code></pre>