Two submit buttons within one <form>

Discussion in 'ASP General' started by Mike P, Aug 14, 2008.

  1. Mike P

    Mike P Guest

    Can you have 2 submit buttons in one <form> element? I have a form with
    a few dropdowns and textboxes that has a submit button to write the data
    to a database, but I also need a submit button next to one of the
    dropdowns to respond to whatever has been selected in the dropdown,
    which will then populate one of the text boxes. How can I do this?


    *** Sent via Developersdex http://www.developersdex.com ***
    Mike P, Aug 14, 2008
    #1
    1. Advertising

  2. Mike P wrote:
    > Can you have 2 submit buttons in one <form> element?


    I don't see why not, but I've never tried it. Why don't you try it and let
    us know?

    > I have a form
    > with a few dropdowns and textboxes that has a submit button to write
    > the data to a database, but I also need a submit button next to one
    > of the dropdowns to respond to whatever has been selected in the
    > dropdown, which will then populate one of the text boxes. How can I
    > do this?
    >

    Well, a second submit button will submit the same form as the first one, so
    you will need to provide some way for the target page to tell whether to
    simply provide the information for your cascading dropdown or to write the
    data to the database.

    See here for some alternative approaches:
    http://classicasp.aspfaq.com/forms/how-do-i-make-one-dropdown-depend-on-another.html

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Aug 14, 2008
    #2
    1. Advertising

  3. Mike P

    Evertjan. Guest

    Bob Barrows [MVP] wrote on 14 aug 2008 in
    microsoft.public.inetserver.asp.general:

    > Mike P wrote:
    >> Can you have 2 submit buttons in one <form> element?

    >
    > I don't see why not, but I've never tried it. Why don't you try it and
    > let us know?
    >
    >> I have a form
    >> with a few dropdowns and textboxes that has a submit button to write
    >> the data to a database, but I also need a submit button next to one
    >> of the dropdowns to respond to whatever has been selected in the
    >> dropdown, which will then populate one of the text boxes. How can I
    >> do this?
    >>

    > Well, a second submit button will submit the same form as the first
    > one, so you will need to provide some way for the target page to tell
    > whether to simply provide the information for your cascading dropdown
    > or to write the data to the database.
    >


    <f...='post'.....
    <input type='submit' name='mySubmit' value='number1'>
    <input type='submit' name='mySubmit' value='number2'>

    ............

    <%
    if request.form("mySubmit")="number1" then
    '' first one pressed
    elseif request.form("mySubmit")="number2" then
    '' other one pressed
    else
    '' possibly js triggered: d...form[x].submit();
    end if

    not tested

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Aug 14, 2008
    #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:
    614
    S. Justin Gengo
    Feb 24, 2004
  2. sree
    Replies:
    2
    Views:
    3,773
    Tim Slattery
    Apr 28, 2004
  3. Replies:
    4
    Views:
    884
  4. Martin Nadoll

    Form Focus with two Submit-Buttons

    Martin Nadoll, Jan 21, 2004, in forum: Javascript
    Replies:
    1
    Views:
    118
    DJ WIce
    Jan 21, 2004
  5. actionwoman63

    Two submit buttons, which one was pressed?

    actionwoman63, Nov 23, 2004, in forum: Javascript
    Replies:
    3
    Views:
    120
    Evertjan.
    Nov 23, 2004
Loading...

Share This Page