Multiple Submit buttons

J

J. B. Moreno

Is it possible to detect inside an onsubmit event /which/ button was
pushed? I searched google and saw lots of suggestions for alternatives,
but nobody outright saying it was impossible. At this point I just want to
know....I'll worry about compatibility and other issues, later...
 
M

Martin Honnen

J. B. Moreno said:
Is it possible to detect inside an onsubmit event /which/ button was
pushed? I searched google and saw lots of suggestions for alternatives,
but nobody outright saying it was impossible.

If you add onclick handlers to the submit buttons to store the actual
submit button e.g.
<form
onsubmit="if (this.submitButton.name == 'submit1') ..."
...>

<input type="submit" name="submit1"
onclick="this.form.submitButton = this;
return true;">

then your code knows which button was clicked but without that it is not
possible.
 
J

J. B. Moreno

If you add onclick handlers to the submit buttons to store the actual
submit button e.g. -snip-
then your code knows which button was clicked but without that it is not
possible.

Thanks. Very clear. I wonder why not, seems like it'd be an obvious
thing....

Anyway, thanks again. Now I can stop trying to find out how to do it...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top