MitchellVII
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?
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?
change the document.form[0].action value to point it to a different action on server side
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
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.
ASKER
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.