title: javascript - how to get value from input with same name (array)
body: <p>I want to use <code>billingname[]</code>  and <code>billingcity[]</code> instead  but I don't know how to write <code>.value</code>  for these input.  (Now I use ordinal number such as billingname1, billingname2  but I don't want ordinal number)</p>
  
  <pre><code>&lt;script&gt;
      function FillBilling(f) {
        if(f.billingtoo1.checked == true) {
          f.billingname1.value = f.shippingname.value;
          f.billingcity1.value = f.shippingcity.value;
        }
          if(f.billingtoo1.checked == false) {
          f.billingname1.value = '';
          f.billingcity1.value = '';
        }
  
        if(f.billingtoo2.checked == true) {
          f.billingname2.value = f.shippingname.value;
          f.billingcity2.value = f.shippingcity.value;
        }
          if(f.billingtoo2.checked == false) {
          f.billingname2.value = '';
          f.billingcity2.value = '';
        }
      }
      &lt;/script&gt;
  
  
  
      &lt;td bgcolor="eeeeee"&gt;
      &lt;b&gt;Mailing Address&lt;/b&gt;
      &lt;br&gt;&lt;br&gt;
      &lt;form id="add_field"&gt;
      Name:
      &lt;input type="text" name="shippingname"&gt;
      &lt;br&gt;
      City:
      &lt;input type="text" name="shippingcity"&gt;
      &lt;br&gt;
      &lt;input type="checkbox" onclick="FillBilling(this.form)" name="billingtoo1"&gt;
      &lt;em&gt;Check this box if Billing Address and Mailing Address are the same.&lt;/em&gt;
      &lt;p&gt;
      &lt;b&gt;Billing Address&lt;/b&gt;
      &lt;br&gt;&lt;br&gt;
      Name:
      &lt;input type="text" name="billingname1"&gt;
      &lt;br&gt;
      City:
      &lt;input type="text" name="billingcity1"&gt;
      &lt;/p&gt;
  
      &lt;input type="checkbox" onclick="FillBilling(this.form)" name="billingtoo2"&gt;
      &lt;em&gt;Check this box if Billing Address and Mailing Address are the same.&lt;/em&gt;
      &lt;p&gt;
      &lt;b&gt;Billing Address&lt;/b&gt;
      &lt;br&gt;&lt;br&gt;
      Name:
      &lt;input type="text" name="billingname2"&gt;
      &lt;br&gt;
      City:
      &lt;input type="text" name="billingcity2"&gt;
      &lt;/p&gt;
      &lt;/form&gt;
      &lt;/td&gt;
  </code></pre>