title: For loop with involving data from forms (form.array[i].checked)
body: <p>Hi I'm making a website that has a user order a pizza. I am using a form to collect all the data and am having troubles with my JavaScript.</p>
  
  <pre><code>&lt;input class="customCheckbox" type="checkbox" name="cheeseCheckbox" value="cheese" onclick="toppingAddedRemoved(this.form)" /&gt;Cheese&lt;br /&gt;
  &lt;input class="customCheckbox" type="checkbox" name="pepperoniCheckbox" value="pepperoni" /&gt;Pepperoni&lt;br /&gt;
  &lt;input class="customCheckbox" type="checkbox" name="hamCheckbox" value="ham" /&gt;Ham&lt;br /&gt;
  &lt;input class="customCheckbox" type="checkbox" name="pineappleCheckbox" value="pineapple" /&gt;Pineapple&lt;br /&gt;
  </code></pre>
  
  <p>This is the relevant HTML that I am trying to get data from. I'm currently only testing with the first input.</p>
  
  <pre><code>function getToppings(form){
      var toppingsNames = new Array("cheeseCheckbox", "pepperoniCheckbox", "hamCheckbox");
      var toppings = new Array();
      var numberOfToppings = 0;
      var i;
      // writeToDIV(form.cheeseCheckbox.checked);
      for (i in toppingsNames){
          if (form.toppingsNames[i].checked === true){
              toppings.push(form.toppingsNames[i].value);
              numberOfToppings++;
          }
      }
      // if (form.cheeseCheckbox.checked === true){
      //   toppings.push(form.cheeseCheckbox.value);
      //   numberOfToppings++;
      // }else if (form.Checkbox.checked === true)
      // writeToDIV(toppings + numberOfToppings);
  }
  </code></pre>
  
  <p>My JavaScript here at the bottom with the if statement is working but that would be tedious set if statements for all of my checkboxes. </p>
  
  <p>My thought was to use a for loop that that replaces the name in the code</p>
  
  <pre><code>form.INPUTNAME.checked
  </code></pre>
  
  <p>with <code>form.toppingsNames[i].input</code>.</p>
  
  <p>This however doesn't seem to work. Does anyone have any suggestions on how I can loop this? Thanks. </p>