I have two submit buttons in a form. How do I determine which one was hit serverside?
Html – Two submit buttons in one form
formshtmlsubmit
Related Topic
- Html – How to align checkboxes and their labels consistently cross-browsers
- C# – How to handle multiple submit buttons in ASP.NET MVC Framework
- Html – Submitting a form by pressing enter without a submit button
- Javascript – How to know which radio button is selected via jQuery
- Html – Prevent users from submitting a form by hitting Enter
- Javascript – jQuery disable/enable submit button
- Javascript – jQuery AJAX submit form
- Javascript – Is it possible to apply CSS to half of a character
Best Answer
Solution 1:
Give each input a different value and keep the same name:
Then in the code check to see which was triggered:
The problem with that is you tie your logic to the user-visible text within the input.
Solution 2:
Give each one a unique name and check the $_POST for the existence of that input:
And in the code: