Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Need help with multiple buttons on single form...

Posted on 2009-12-17
7
Medium Priority
?
228 Views
Last Modified: 2012-05-08
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?
0
Comment
Question by:MitchellVII
7 Comments
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 26072103
change the document.form[0].action value to point it to a different action on server side
0
 
LVL 5

Author Comment

by:MitchellVII
ID: 26072174
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

0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 26072196
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Author Comment

by:MitchellVII
ID: 26072213
Guys walk me through it, ur talking above my head here :)
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 26072216
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

0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 1400 total points
ID: 26072242
Just to expand slightly:
'// assuming you have a form defined something like this
<form method="post">

   <input type="submit" name="PrevButton" value="Previous" /><br />
   <input type="submit" name="NextButton" value="Next" /><br />

</form>


'// you could then use the following at the server-side
<%
If Request.Form("PrevButton") <> "" then
    Response.Redirect("http://www.myWebsite.biz/forms/Previous_Form.asp?ProspectID=" & Upload.Form("ProspectID")) 
ElseIf Request.Form("NextButton") <> "" then
    Response.Redirect("http://www.myWebsite.biz/forms/Next_Form.asp?ProspectID=" & Upload.Form("ProspectID")) 
End if
%>

Open in new window

0
 
LVL 28

Assisted Solution

by:sybe
sybe earned 600 total points
ID: 26078250
Give the both submit buttons the same name. In the code below they are supposed to be named "submitbutton"
<%
If Request.Form("submitbutton") = "Next" Then
   Response.Redirect("Next.asp")
Else
   Response.Redirect("Previous.asp")
End If
%>

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question