My problem is that I made a page to work basically like the jQuery demo of a modal-form dialog box, except that after you've added all the rows you want, it will submit them at the end. The reason i don't just AJAX this to work where as the rows are created they are saved, is because the form contains dynamic rows created from PHP & SQL which are linked to the rows that get added using the modal-form and need to be processed once all the rows have been added.
The form page has a bunch of rows created using PHP from 1 to X.
<table>
<form action="submitform.php" method="POST">
<input type="hidden" name="order" value="X">
<tr><td><input type="text" name="1" value=""</td></tr>
<div id="1"></div>
<tr><td><input type="text" name="2" value=""</td></tr>
<div id="2"></div>
<tr><td><input type="text" name="3" value=""</td></tr>
<div id="3"></div>
...
...
<tr><td><input type="text" name="X" value=""</td></tr>
<div id="X"></div>
</table>
When the text fields are changed, a popup asks for more information and then adds rows below the text box that has changed.
The above <DIV>
tags are filled with extra form elements using jQuery when the popup is completed.
itemHiddenInfo = "<input type='hidden' name='"+temp2+"A"+x+"' value='"+itemNum+"_"+itemID+"'/>";
$( "#"+itemDiv ).append("<tr id='"+temp2+"_"+x+"R' class='"+temp2+"'>" +
"<td>" + itemHiddenInfo + itemMat + "</td>" +
"<td>" + itemQty + "</td>" +
"<td>" + itemNote + "</td>" +
"<td>" + "<button id='"+temp2+"_"+x+"' class='remmy'onclick=$('#'+this.id+'R').remove()>REMOVE</button>" + "</td>"+ "</tr>");
And everything visually looks great, the rows appear and disappear when they are suppose to and using the Firefox development tools, I can see the DOM has been modified to include all the elements i have added, but when i try to submit the form u开发者_如何学Csing either a "SUBMIT" button or via jQuery AJAX and .sequence()
to gather the form elements, neither way will recognize any of the new form elements added in the <DIV>
's.
The <DIV>
on the page which is used to display the modal-form is dynamically generated using another PHP file which is populated using the $.get
method with the results populating the forms <DIV>
. The fields which get populated on this form do get submitted which is why it seems odd that the other fields added do not.
I've searched around and it seems like I am doing everything correctly but it doesn't want to cooperate. Am I doing trying to do something that is impossible or am I missing something here?
Any help is greatly appreciated.
Try to use live
or delegate
methods for submitting form
精彩评论