Link to home
Start Free TrialLog in
Avatar of MitchellVII
MitchellVIIFlag for United States of America

asked on

Need help with multiple buttons on single form...

Hi,

I have a webform that the user can click one of two buttons at the bottom.  Both buttons save the changes on the form to a MySQL Database, but the "Previous" button returns to one form and the "Next" button goes to a different form.

My <form> statement points to a single .asp script that saves the data.  What I want is for that script to somehow tell which button the user clicked and then redirect to the appropriate form.

What would the code for that redirect based upon the button click look like?
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

change the document.form[0].action value to point it to a different action on server side
Avatar of MitchellVII

ASKER

Sorry, i'm a noob.

Let's say my current .asp script looks like this:

<%Response.Redirect("http://www.myWebsite.biz/forms/DocEPW_IT_Group.asp?ProspectID=" &  Upload.Form("ProspectID"))
%>

How would I write the code so that it redirected based upon which button was clicked?  Sorta like:

If user clicks "Previous" button, then
    Response.Redirect("http://www.myWebsite.biz/forms/Previous_Form.asp?ProspectID=" & Upload.Form("ProspectID"))
ElseIf user clicks "Next" button, then
    Response.Redirect("http://www.myWebsite.biz/forms/Next_Form.asp?ProspectID=" & Upload.Form("ProspectID"))
End if

Or you can check Request.Form at the server-side. There should be an entry in there that matches the button that submitted the form.
Guys walk me through it, ur talking above my head here :)
You could use:
If Request.Form("NameOfPrevButton") <> "" then
    Response.Redirect("http://www.myWebsite.biz/forms/Previous_Form.asp?ProspectID=" & Upload.Form("ProspectID")) 
ElseIf Request.Form("NameOfNextButton") <> "" then
    Response.Redirect("http://www.myWebsite.biz/forms/Next_Form.asp?ProspectID=" & Upload.Form("ProspectID")) 
End if

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial