single form > multiple post options

TechBoyJK

Lifer
Oct 17, 2002
16,699
60
91
I'm trying to figure out how to have two different submit buttons for one form, with each going to a different page. I'd also like to avoid using Javascript to do so. aka no 'history(-1)'

The purpose is so that users can either approve the displayed info, "submit" and move on, or dissapprove, "go back" and correct the info.

I have a form, and when users hit submit, a page with the info they entered is displayed. It gives them a chance to review the information.

Basically

Form

V

Verification Page

V

Data submitted

On the verification page, I'd like to add a button that says "GO BACK" and when the click it, the information is posted back to the original form. This would require having two options for "post" in the form declaration, and the post option being determined by the form button.
 

Snapster

Diamond Member
Oct 14, 2001
3,916
0
0
I presume this is php as if you used .net you could just have a different event firing for each button.

You only need 1 script to post to and just use the posted vars to gather which button was clicked and decide what to do, eg:

<input type="submit" name="back" value="back">
<input type="submit" name="continue" value="continue">

then in the code you catch it like:

if (empty($back)){
// save info and move on
}
else {
// go back to the previous page
}

 

GilletteCat

Member
Dec 28, 2001
181
0
0
Again, this is if you are NOT using .Net, because otherwise you would just code each event in the code-behind or use PostBackURL parameter:
...
<form name="Form1" method="post">
...
<input type="button" name="btnBack" value="Go Back" onclick="document.Form1.action='InitialForm...';document.Form1.submit()"> 
<input type="button" name="btnContinue" value="Continue" onclick="document.Form1.action='FinalProcessConfirm...';document.Form1.submit()">

...
</form>
InitialForm... and FinalProcessConfirm... need to be proper names of respective pages with extensions.