title: Variable List Form Input Jquery and PHP
body: <p>So I am creating a form that has a feature(s) input. It starts off with only 1 but the number may increase. By clicking on a button I will append a new text box for new feature to be written into it via Jquery.</p>
  
  <p>JsFiddle: <a href="https://jsfiddle.net/kmckeow/ewnetzqx/" rel="nofollow noreferrer">https://jsfiddle.net/kmckeow/ewnetzqx/</a></p>
  
  <p>Issue 1:error from java script saying that I cannot use input.attr().</p>
  
  <p>Issue 2:When I do get this JavaScript to work, how am I supposed to reference a variable number of elements i.e. (feature1, feature2, feature3, ...) in PHP. When I submit a form with post I usually access the information in each element via it's name. How can I do that when I am not sure how many features there will be.</p>
  
  <p>HTML:</p>
  
  <pre><code>    &lt;div id="new_product"&gt;
        &lt;form action="" method="post" enctype="multipart/form-data"&gt;
         &lt;p&gt;
          &lt;label for="feature1"&gt; Feature(s): &lt;/label&gt;
          &lt;input type="text" name="feature1" /&gt;
          &lt;button type="button" class="btn btn-primary" id="add_feature"&gt;Add Feature&lt;/button&gt;
         &lt;p&gt; 
         &lt;input type="submit" value="Submit" name="submit"&gt;
        &lt;/form&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>JQuery:</p>
  
  <pre><code>    var feature_count=1;
      var feature_count_old=0;
      $( "#add_feature" ).click(function() {
         feature_count_old=feature_count;
         feature_count+=1;
         var input = document.createElement("input");
         input.attr('name', 'feature' + feature_count);
         input.attr('type', 'text');
         $("input[name='feature'+feature_count_old]").after(input);
      });
  </code></pre>