Note that there are some explanatory texts on larger screens.

plurals
  1. POForm fields added via AJAX fail to load into the $_POST array
    text
    copied!<p>I've got a plain and simple HTML form which allows people to order some brochures. The form first loads with something looking a little like this:</p> <pre><code>&lt;script type="text/javascript"&gt; var tableRowN = 1; &lt;/script&gt; &lt;form id="Order" name="Order" method="post" action="includes/orderCheck.php"&gt; &lt;input id="name" type="text" name="name" width="100" /&gt; &lt;table id="orderingTable"&gt; &lt;tr class="lastRow"&gt; &lt;td&gt;&lt;div id="itemGroupdiv1"&gt; &lt;input type="text" class="disabled" name="itemGroup1" id="itemGroup1" /&gt; &lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;div id="itemCodediv1"&gt; &lt;input type="text" name="itemCode1" id="itemCode1" class="disabled" /&gt; &lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;div id="itemCodeVersiondiv1"&gt; &lt;input type="text" class="disabledSmall" id="itemcodeversion1" name="itemcodeversion1" /&gt; &lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input type="submit" name="submit" id="submit"/&gt; &lt;/form&gt; </code></pre> <p>Then when the user wants to add a new line to the table he can click a button which fires the following javascript function to grab the new table code via AJAX and insert it.</p> <pre><code>function createItemLine() { tableRowN++; $('tr.lastRow').attr('class', ''); $('#orderingTable').append('&lt;tr class="lastRow"&gt;&lt;/tr&gt;'); $.ajax({ url: "/orderingTable.php?rNumber=" + tableRowN, cache: false, success: function(html){ $("tr.lastRow").append(html); alert('loaded'); } }); } </code></pre> <p>The AJAX function then runs off to a PHP script which creates the next line, rolling the IDs and Names etc with +1 to the number.</p> <pre><code>&lt;td&gt;&lt;div id="itemGroupdiv2"&gt; &lt;input type="text" class="disabled" name="itemGroup2" id="itemGroup2" /&gt; &lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;div id="itemCodediv2"&gt; &lt;input type="text" name="itemCode2" id="itemCode2" class="disabled" /&gt; &lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;div id="itemCodeVersiondiv2"&gt; &lt;input type="text" class="disabledSmall" id="itemcodeversion2" name="itemcodeversion2" /&gt; &lt;/div&gt;&lt;/td&gt; </code></pre> <p>So so far, nothing suprising? Should all be pretty straight forward...</p> <p>The problem is that when I add new lines (In Firefox and Chrome) the new lines are completely ignored by the form submission process, and they never get passed through into the $_POST array.</p> <p>Is this a known problem? I've not come across this before...</p> <p>Thanks for any pointers, H</p>
 

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