A form that does not represent dynamically generated inputs (jQuery)

Hi, I am trying to dynamically generate some inputs for my form, but not to publish new nested data while I was searching, and the only thing I could find was to make the form direct children tag body, and, as in the design of my application, this is not possible , so someone can know what is happening and how to solve it? And no, this does not work with .live() .

 HTML <form name="order" id="newOrder" action="../core/query.php" method="post"> <input type="text" value="Search" id="itemSearch" class="search"/> <input type="hidden" id="itemAdd"/> <button type="button" class="boton" id="additem">Add</button> <br> <div id="items"></div> <br> <button type="submit" class="boton" > Submit</button> <button type="reset" class="boton" style="float:right;"> Cancel</button> </div> </form> Javascript $('#additem').click(function(){ if($('#itemAdd').val()){ var rawr = $('<div></div>') .css('display','none') .html( '<br><table><td>' +currItem.label+'</td><td> Size ' +currItem.size+'</td><td class="right">$'+currItem.price +'</td></table> <input type="hidden" name="contents[]" value="' +currItem.value+'"/>'); var mhm = currItem.price; rawr.appendTo('#items').toggle(500).click(function(){ $(this).toggle(500,function(){ $(this).remove(); }); $('#total').fadeOut("fast",function(){ total = (parseFloat($(this).text())-parseFloat(mhm)).toFixed(2); $(this).text(total).fadeIn("fast"); }); }); $('#total').fadeOut("fast",function(){ total = (parseFloat($(this).text())+parseFloat(mhm)).toFixed(2); $(this).text(total).fadeIn("fast"); currItem=null; }); } }); 

Therefore, I mainly use jQuery UI autocomplete with remote JSON, which when I click the #addItem button creates a table with some text and hidden input with an identifier from the database, everything is displayed correctly, but when they are sent, they are not placed and serialized.

+7
source share
2 answers

It may take time to debug. Are you sure this is not POSTED? The following jsFiddle uses your exact code, and when the form is submitted, you can see the POSTed values ​​on the Firebugs NET tab.

http://jsfiddle.net/s6Umg/

Check your real-life example using the NET tab in Firebug to see if the values ​​have actually passed. There may be a problem accessing the data after it is published. How do you access the POST data in the query.php file?

+2
source

Form elements must have the "name" attribute, not just the "id" ... or their data will not be sent.

+8
source

All Articles