SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Two Submit buttons in a single Form

    Hello all,

    I wanted to know if it's possible to have 2 submit buttons in a single form, but each with a different action (i.e. submits the form data to a different page).

    I'm considering this approach for a shopping cart, where one button will be to update the quantities in the shopping cart (which would load the same page again, but with the modifications), or proceed to checkout (and submitting the form data to another page to continue the purchase process)..

    Also, if there's another simpler way of implementing this functionality, then I'm all eyes...

    All the best,
    Haider

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I didn't expect to find a solution this quick!

    I initially posted my question here (Javascript Forum) because I thought the solution would be to use DOM manipulation.

    However, I found out that I can use 2 (or more) submit buttons with the same name, and have my server-side script (PHP) determine which button was pressed based on the value of the button (i.e. the text displayed on the button). This seems to be a very easy implementation that I can use...

    If you know of any other implementation that might work better, feel free to post!

  3. #3
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what you can do is place a regular button that calls a javascript function.
    the javascript function will get a page name from the button and change the form action to the newly recived page. after the change it will submit the form.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ophir, your solution sounds better than mine.. thanks for the tip!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •