I have a form that contains multiple submit buttons. How can I pass a parameter submitting the form to find out which submit has been pressed? No JavaScript allowed.
Assuming you have 2 or more buttons like this:
<input type="submit" name="SubmitButtonOne" value="Button One"/>
<input type="submit" name="SubmitButtonTwo" value="Button Two"/>
Check for the names of the buttons, in the submitted (POST) data.
In PHP for example, that would be:
if (isset($_POST['SubmitButtonOne'])){
//Do something.
}elseif (isset($_POST['SubmitButtonTwo'])){
//Do something.
}
Or, check for the submitted values:
<input type="submit" name="formSubmit" value="Button One"/>
<input type="submit" name="formSubmit" value="Button Two"/>
switch ($_POST['formSubmit']) {
case 'Button One':
//Do something.
break;
case 'Button Two':
//Do something else.
break;
}
Only the button that submitted the form will be sent to the server. So just create multiple submit buttons with different names, and then check which button is present in the POST data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With