471,338 Members | 937 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

Multiple Submit buttons

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...

--
J.B.Moreno
Jul 23 '05 #1
2 2678


J. B. Moreno wrote:
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.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Ma***********@gmx.de wrote:
J. B. Moreno wrote:
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.

-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...

--
J.B.Moreno
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Matt | last post: by
3 posts views Thread by D. Shane Fowlkes | last post: by
5 posts views Thread by Lau Lei Cheong | last post: by
5 posts views Thread by Alex Maghen | last post: by
4 posts views Thread by =?Utf-8?B?YzY3NjIyOA==?= | last post: by
9 posts views Thread by mosscliffe | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.