ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 1st, 2003, 03:20 AM
j1nk5 j1nk5 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 1 j1nk5 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Changing the action on a form before submitting

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.

Reply With Quote
  #2  
Old November 2nd, 2003, 02:10 AM
LabRaTT's Avatar
LabRaTT LabRaTT is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Boston, MA, USA
Posts: 23 LabRaTT User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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%>

Reply With Quote
  #3  
Old November 3rd, 2003, 08:40 AM
smartcino smartcino is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 1 smartcino User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old November 5th, 2003, 04:34 AM
ShermanPeabody ShermanPeabody is offline
CDONT[RE:"member"]
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: United States
Posts: 35 ShermanPeabody User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 6 sec
Reputation Power: 5
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"";

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Changing the action on a form before submitting


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway