Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First things first, ID's need to be unique, so when a new date pair is added, append a qualifier on the end of the id:</p> <pre><code>&lt;input type="text" name="startDate[]" id="startDateInput1"&gt; &lt;input type="text" name="enddate[]" id="endDateInput1"&gt; &lt;input type="text" name="startDate[]" id="startDateInput2"&gt; &lt;input type="text" name="enddate[]" id="endDateInput2"&gt; </code></pre> <p>Or better yet, use a class:</p> <pre><code>&lt;input type="text" name="startDate[]" class="startDateInput"&gt; &lt;input type="text" name="enddate[]" class="endDateInput"&gt; &lt;input type="text" name="startDate[]" class="startDateInput"&gt; &lt;input type="text" name="enddate[]" class="endDateInput"&gt; </code></pre> <p>Then you can apply some jQuery voodoo whenever you'd like (button click, submit, etc):</p> <pre><code>$('#myButton').click(function(){ // Our ajax post data. For example, $_POST['startDates'][2] would // give you the 3rd start date in your php file. var data = { startDates: new Array(), endDates: new Array() }; // Loop through each date pair, extract its value, and add it to our post data $('.startDateInput').each(function(){ data.startDates.push(this.val()); }); $('.endDateInput').each(function(){ data.endDates.push(this.val()); }); // Load it! $('#result').load('doSomething.php', data); }); </code></pre> <p><em>Note: Above code is not tested, just an example of one possible solution.</em></p> <p>Hope that helps. Oh, and <a href="http://images.wikia.com/familyguy/images/c/cf/Adam_We.JPG" rel="nofollow">obligatory Family Guy reference</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload