title: Duplicate text field with jQuery and store in DB in Wordpress?
body: <p>This time I really require assistance in creating a multiple text fields and save them in database. For now I know how create additional text fields with 'add' link, but if I create, let's say, 10 text fields and populate them with text only the first one is added to database, other 9 not, and I need to know why?? (Probably I need to create a php function, which catches every click on 'Add' button and crates new array???)</p>
  
  <p>1.array storing data:</p>
  
  <pre><code>array( "name" =&gt; "TEST",
      "type" =&gt; "section"),
  array( "type" =&gt; "open"),
  
          array( "name" =&gt; "Button:",
              "desc" =&gt; "Another text button",
              "id" =&gt; $shortname."_testbutton",
              "type" =&gt; "textbox",
              "std" =&gt; ""),
  
  array( "name" =&gt; "TEST2",
      "type" =&gt; "section2"),
  
  array( "type" =&gt; "close"),
  </code></pre>
  
  <p>2.Text fields:</p>
  
  <pre><code>&lt;h2&gt;
      &lt;a href="#" id="addbutton"&gt;Add&lt;/a&gt;
  &lt;/h2&gt;
  &lt;div id="textfields"&gt;
      &lt;p&gt;
      &lt;label for="&lt;?php echo $value['id']; ?&gt;"&gt;&lt;/label&gt;
      &lt;input type="text" id="&lt;?php echo $value['id']; ?&gt;" size="20" name="&lt;?php echo $value['id']; ?&gt;" value="&lt;?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'])  ); } else { echo $value['std']; } ?&gt;" placeholder="Input Value" /&gt;
      &lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>3.jQuery</p>
  
  <pre><code>jQuery(function($) {
          var scntDiv = $('#textfields');
          var i = $('#textfields p').size() + 1;
  
          $('#addbutton').live('click', function() {
                  $('&lt;p&gt;&lt;label for="test_testbutton"&gt;&lt;/label&gt;&lt;input type="text" id="test_testbutton" size="20" name="test_testbutton_' + i +'" value="" placeholder="Input Value" /&gt; &lt;a href="#" id="removebutton"&gt;Remove&lt;/a&gt;&lt;/p&gt;').appendTo(scntDiv);
                  i++;
                  return false;
          });
  
          $('#removebutton').live('click', function() { 
                  if( i &gt; 2 ) {
                          $(this).parents('p').remove();
                          i--;
                  }
                  return false;
          });
  });
  </code></pre>
  
  <p>PS. That's for Wordpress theme options page.</p>
  
  <p><strong>EDIT!!!</strong></p>
  
  <p>I managed to create functioning loop which gets the number of created textfields, gets their values, puts everything back into textfields and preserves everything. I changed jQuery a bit:</p>
  
  <pre><code>name="test_testbutton_' + i +'"
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>name="test_testbutton[]"
  </code></pre>
  
  <p>as Adam Erstelle suggested, and I looped everything in:</p>
  
  <pre><code>&lt;?php
  if (isset($_REQUEST['test_testbutton']) &amp;&amp; is_array($_REQUEST['test_testbutton'])) {
  $numbers = $_REQUEST['test_testbutton'];
  foreach ($numbers as $number) {?&gt;
  &lt;input type="text" id="&lt;?php echo $value['id']; ?&gt;" size="20" name="test_testbutton[]" value="&lt;?php echo $number; ?&gt;" placeholder="Input Value" /&gt;&lt;a href="#" id="removebutton"&gt;Remove&lt;/a&gt; &lt;?php
  }}?&gt;
  </code></pre>
  
  <p><strong>Now Everything is stored in array as it supposed to be, but I have a problem with feching textfields' values to frontend and display them...????</strong></p>