
Originally Posted by
djr33
<form ...>
<input(s)>
<[submit button]>
</form>
...but what if you want to have two submit buttons?
Make the submit buttons successful controls.
For a submit button to work, one usually only needs to write:
HTML Code:
<input type="submit" value="...">
Unlike the other controls within the form, the value of that submit button won't be sent with the rest of the form data. This is because it isn't successful: in this case, it has no name attribute[1].
To use two (or more) submit buttons, name them (the same name, if preferred). One can then check server-side which was pressed by looking for the name/value pair. Only the activated button will be submitted.
Be careful with multiple submit buttons, though. Users are often familiar with the ability to submit a form just by pressing Enter. Usually, this action activates the first submit button in document order, which may or may not be the desired result.
Mike
[1] The HTML Specification defines successful controls.
Bookmarks