I have a form in which there are sets of elements that are cloned. The form allows a user to input multiple vehicles, with multiple attributes being cloned (year, make, model, etc). I have successfully cloned the elements and they have unique names. However, after the form is posted, only the elements that were not dynamically created get posted and are there by accessible using PHP. If you need to look at my code, I can post it on here, it's just a little lengthy. Thanks!
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I had a rough look at your code. I think the problem is after submission of the form. The Elements are dynamically generating properly.
回答2:
I know the OP is rather old, but just in case someone is encountering this problem as well... a way to post dynamically added or modified elements' values to PHP is to use jQuery's serialize()
(which the OP seems to be using anyway):
$( "form" ).submit( function ( event ) {
event.preventDefault();
var url = $( this ).attr( "action" ),
data = $( this ).serialize();
$.post( url, data ).done( function() {
// Redirect to a "sent" page or something
} )
.fail( function() {
//etc etc
} );
});