I have a form with two submit buttons and both submit buttons have a different name so I can differentiate which button was clicked. The problem are the hidden values. For button1
, I would like to send value=1
, for button2
, I would like to send value=2
in a hidden value. But when button1
was clicked, then hidden value=2 goes into the POST instead of value=1.
<form action="destination.php" method="POST">
<input type="hidden" name="car" value="1">
<button type="submit" name="button1" value="button1">Button 1</button>
<input type="hidden" name="car" value="2">
<button type="submit" name="button2" value="button 2>Button 2</button>
</form>
How can I send hidden value=1 when button1
was clicked and hidden value=2 when button2
was clicked?
Do I have to create a form for each submit button and the associated hidden values or is there a different way to pass hidden values with only one form?