Multiple Submit buttons

Discussion in 'Javascript' started by J. B. Moreno, May 13, 2005.

  1. J. B. Moreno

    J. B. Moreno Guest

    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
     
    J. B. Moreno, May 13, 2005
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, May 13, 2005
    #2
    1. Advertising

  3. J. B. Moreno

    J. B. Moreno Guest

    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
     
    J. B. Moreno, May 13, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. D. Shane Fowlkes
    Replies:
    3
    Views:
    644
    S. Justin Gengo
    Feb 24, 2004
  2. Lau Lei Cheong

    Multiple Submit Buttons

    Lau Lei Cheong, Jun 21, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    2,907
    Lau Lei Cheong
    Jun 23, 2004
  3. Steve C. Orr [MVP, MCSD]

    Re: Multiple submit buttons on one page

    Steve C. Orr [MVP, MCSD], Mar 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    457
    Jeffrey Palermo
    Mar 7, 2005
  4. Replies:
    4
    Views:
    981
  5. sandyde2
    Replies:
    2
    Views:
    198
    sandyde2
    Oct 2, 2003
Loading...

Share This Page