Well this is not a question but just for my information (since I can think of about 4 different workarounds to make it work. However I have a form (nothing special) but the submit button has something to do with The specific value associated with it.
After submitting the form, I check the name.
if(isset($_POST['submitDocUpdate'])){ //do stuff
However, one time I tried to submit the form via Javascript instead of the submit button.
document.getElementById("myForm").submit();
Everything is working fine except 1 problem. When I look at the $_POST value submitted via the javascript method, it does not include SubmitDocUpdate. I get all other values of the form but not the submit button value.
Like I said, I can think of a few ways to fix it (using a hidden variable, checking isset on another form variable, etc.), but I just want to know if this is the correct behavior for Submit(), Because it doesn't seem very intuitive to me. Thanks in advance.
Use jQuery 1.0 or higher:
$('input[type="submit"]').click();
I was actually solving the same problem when I stumbled across this post. click() without any parameters triggers a click event on any element you select:http://api.jquery.com/click/
Yes, this is the correct behavior of
HTMLFormElement.submit()
The reason the submit button value is not sent is that HTML forms are designed to send the value of a submit button that is clicked (or otherwise activated). This allows for multiple submit buttons per form, for example in scenarios where you need "preview" and "save" actions.
Since you are submitting the form programmatically, there is no explicit user action on the single submit button, so nothing is sent.