I have one form that has several elements and two submit buttons, one is “Save” the other is “Delete”. On the “Delete” button I am using jQuery dialog to confirm user wants to delete. Then if they confirm, I submit the form. The problem is jQuery.submit() doesn’t include the original submit button when it is posted so I can’t distinguish on the server a Delete from a Save since they are both using the same form. If I remove the jQuery dialog then the submit button value is posted as expected. This HAS to be very common and I am hoping someone can share a solution. I’ve searched around and can’t find anything useful (is it just me or is google sucking lately?)
Thanks for any help…
EDIT:
The submit buttons do have names and values set. It works fine if don’t use jQuery.submit()
Based on karim79’s answer:
UPDATE:
I just realized the above code is probably not what you are looking for:
If you are calling submit on the form element itself (
$("form").submit();) you will need something like this:Which will add the first button element’s name and value to the DOM right before the form is submitted (I’m not sure what the default browser behavior is here). Note that this doesn’t remove the
tempElementfrom the DOM. If there is an error and the form isn’t submitted the element will remain and you will have problems if you don’t take care of this.