|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello,
I want a form to submit to a different page depending on what selection has been made in a dropdown option box. However something is going wrong my code looks as follows: <%@ Language=VBScript %> <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <% function submit1_onclick() if form1.after.value = "MakeOwnWay" then document.form1.action = "final.asp" elseif form1.after.value = "TaxiHome" then document.form1.action = "pickup.asp" elseif form1.after.value = "Lodgings" then document.form1.action = "lodgings.asp" endif document.form1.method = "post" document.form1.submit() end function %> </HEAD> <BODY> <form id=form1 name=form1 action=Mission4.asp method=post> <INPUT type="hidden" id=FirstName name=FirstName value="<% =Request.Form("FirstName") %>"> <INPUT type="hidden" id=Surname name=Surname value="<% =Request.Form("Surname") %>"> <INPUT type="hidden" id=AgentName name=AgentName value="<% =Request.Form("AgentName") %>"> <INPUT type="hidden" id=Diet name=Diet value="<% =Request.Form("Diet") %>"> <SELECT id=After name=After> <OPTION value=MakeOwnWay>Agent Continues Alone</OPTION> <OPTION value=TaxiHome>HQ Arrange Pickup</OPTION> <OPTION value=Lodgings>Agent Requires Secret Overnight Lodgings</OPTION> </SELECT> <INPUT type="button" value="Continue" id=submit1 name=submit1 onclick="submit1_onclick()"> </form> </BODY> </HTML> I'm quite new to this so it may be a silly mistake. |
|
#2
|
||||
|
||||
|
here is a way
here is one way.... i used cases... to make this work make sure you name the page testbox.asp or change the action"" in the form
<% iChoice = Request.QueryString("Choice") Select Case iChoice Case "page" x_FirstName = Request.Form("FirstName") x_Surname = Request.Form("Surname") x_AgentName = Request.Form("AgentName") x_Diet = Request.Form("Diet") IF Request.Form("after") = "MakeOwnWay" Then submitpage = "final.asp" ElseIF Request.Form("after") = "TaxiHome" Then submitpage = "pickup.asp" ElseIF Request.Form("after") = "Lodgings" Then submitpage = "lodgings.asp" End IF Response.Redirect submitpage & "?Firstname=" & x_FirstName & "&Surname=" & x_Surname & "&AgentName=" & x_AgentName & "&Diet=" & x_Diet Case Else %> <form action="testbox.asp?Choice=page" method="post"> <INPUT type="hidden" id=FirstName name=FirstName value="<% =Request.Form("FirstName") %>"> <INPUT type="hidden" id=Surname name=Surname value="<% =Request.Form("Surname") %>"> <INPUT type="hidden" id=AgentName name=AgentName value="<% =Request.Form("AgentName") %>"> <INPUT type="hidden" id=Diet name=Diet value="<% =Request.Form("Diet") %>"> <SELECT id=After name=After> <OPTION value="MakeOwnWay">Agent Continues Alone</OPTION> <OPTION value="TaxiHome">HQ Arrange Pickup</OPTION> <OPTION value="Lodgings">Agent Requires Secret Overnight Lodgings</OPTION> </SELECT> <INPUT type="submit" value="Continue"> </form> <%End Select%> |
|
#3
|
|||
|
|||
|
The main error is thatthe submit1_onclick() must be executed on the client side so must be within <SCRIPT LANGUAGE="VBSCRIPT"> and </SCRIPT>
The code written inside <% %> is executed by the server. I will try to test and fix your code asap. Bye |
|
#4
|
|||
|
|||
|
Youll Need to edit this to fit your needs but this JavaScript function sets which page to submit the form to Then Submits the form to the correct page.
function SubmitEntryValues(V){ if (V==1) document.SubmitEntryData.action = "ViewDay.asp"; if (V==2) document.SubmitEntryData.action = "ViewWeek.asp"; if (V==3) document.SubmitEntryData.action = "ViewMonth.asp"; document.SubmitEntryData.submit(); Call the function from the onclick method of your button. You probably dont need to pass it a variable just use something different in the if condition. if (form1.after.value == "MakeOwnWay") form1.action = "final.asp""; |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Changing the action on a form before submitting |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|