Neo
Neo

Reputation: 13881

Different inputs with multiple submit buttons in html form

I want a form which has two submit buttons. The form has some hidden fields which are common while submitting both buttons. So with different buttons, I want to post a different set of inputs/values to the same target url. Something like

<form method='POST' action='/method/data'  >
<input type="text" name="field1" /> 
<!--...some other fields...-->
<input type="submit" name="m1" value="v1" /> 
<input type="submit" name="m2" value="v2" /> 
</form>

Is it possible that field1 should be submitted only when m1 button is pressed and not with m2?

Upvotes: 0

Views: 850

Answers (1)

Pekka
Pekka

Reputation: 449395

Is it possible that field1 should be submitted only when m1 button is pressed and not with m2?

Not without Javascript.

But this shouldn't be necessary in the first place: You will be able to tell on server side which button was clicked, and you can exclude the field there.

Upvotes: 1

Related Questions