title: Get value of dynamic input element in form object
body: <p>My question is: How do I reference a dynamic 'name' of an input element in a form?</p>
  
  <p>For instance, with the following HTML:</p>
  
  <pre><code>&lt;form&gt;
      &lt;input type="text" name="qty1" value="input1" /&gt;
       &lt;input type="text" name="qty2" value="input2" /&gt;
       &lt;input type="text" name="qty3" value="input3" /&gt;
  
      &lt;input type="submit" value="Submit" onClick="checkVal(this.form); return false;" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Javascript: </p>
  
  <pre><code>function checkVal(form) {
      for (var i = 1; i &lt;= 3; i++) {
          alert(form.qty+i.value);  // Here's where my problem is..
      }
  }
  </code></pre>
  
  <p>The above javascript does not work. The alert is outputting <code>NaN</code>. </p>
  
  <p>How do I reference <code>qty1</code>, <code>qty2</code>, and <code>qty3</code> in a for loop using <code>i</code> variable?</p>
  
  <p>Here's a jsfiddle:  <a href="http://jsfiddle.net/MRzWf/" rel="noreferrer">http://jsfiddle.net/MRzWf/</a></p>