title: Dynamically, check radio button with for loop
body: <p>I'm trying to create a 5 star radio picker.</p>
  
  <p>This is the 1 of the radio buttons:</p>
  
  <pre><code>&lt;input onclick="check(3)" type="radio" name="three" id="num_3_star" value="3"&gt;
  </code></pre>
  
  <p>After the method gets called and "3" is passed on this is my javascript function:</p>
  
  <pre><code>function check(stars)
  {
      for(i = 0 ; i &lt; stars; i++)
      {       
          document.getElementById("num_" + stars + "_star").checked = true;
      }   
  }
  </code></pre>
  
  <p>When I run the code, it does not perform the checked to = true, though if remove the for loop, it works just fine. </p>
  
  <p>Any ideas why the for loop is preventing from checking the radio boxes?</p>
  
  <p>This is my entire code:</p>
  
  <pre><code>&lt;script&gt;
  function check(stars)
  {
      for(i = 0 ; i &lt; stars; i++)
      {       
          document.getElementById("num_" + stars + "_star").checked = true;
      }   
  }
  &lt;/script&gt;
  
  &lt;form&gt;
  &lt;input onclick="check(1)" type="radio" name="one" id="num_1_star" value="1"&gt;
  &lt;input onclick="check(2)" type="radio" name="two" id="num_2_star" value="2"&gt;
  &lt;input onclick="check(3)" type="radio" name="three" id="num_3_star" value="3"&gt;
  &lt;input onclick="check(4)" type="radio" name="four" id="num_4_star" value="4"&gt;
  &lt;input onclick="check(5)" type="radio" name="five" id="num_5_star" value="5"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Thanks! </p>