I have a form with two buttons, each with onclick = this.form.submit(). I have a hidden field in the form, and I would like the value of the field to be different based on which
Forgive me if the answer to this
seems obvious, but why use a hidden
field at all? already works;
browsers will send the
value
of
the submit button that was clicked,
along with the rest of the form
data.
The
element works perfectly in
Chrome/Safari/Firefox, but fails in
IE7 (as Lèse majesté pointed out in
his comment above); if you don't
care about IE, that'd be the way to
go.
You could also use an
element, just remember that the browser submits
it as two fields:
name.x
and name.y
. Also,
you can't set its value, but that shouldn't be a
problem if you're only interested in the
presence of the field.