When you submit a form, does the button that was clicked get posted also?
When you submit a form, does the button that was clicke开发者_如何学编程d get posted also?
Yes it does. As long as you set both the name
and value
:
<INPUT name="submit" value="submit" type="submit"/>
In fact you can have multiple submit buttons on the same page and you can detect which one is clicked on by checking for this pair.
Yes, submit buttons are submitted with their name/value.
But especially when doing i18n, it's recommended to rely only on the name, not the value though so you don't have to check for i18n'd values in your server-side code but just for the existence of certain POST arguments..
If it is part of the submitted form, yes.
When a form is submitted, every one of it's "input" elements are posted; and if you submit a form by clicking it's submit button (which is another input) you'll definitely post it too.
If you don't want to do that, you can always submit you form via javascript : form.submit();
.
You can add a button element to your form and attach a function that submits the form to it's click event.
<button type="button" onclick="document.getElementsByTagName('form')[0].submit();"> Submit the form! </button>
That way you'll have a submit button inside your form that is not submitted:)
精彩评论