Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

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 ASP Free Forums Sponsor:
  #1  
Old September 17th, 2004, 05:01 PM
Chowyunli Chowyunli is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 4 Chowyunli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How do I redirect a form

I've got a problem and would be grateful for any help! I've
working on a form and would like to redirect users to diff.
pages based on the option they select.If it helps any, The option's a session
variable.

Thanks

Reply With Quote
  #2  
Old September 20th, 2004, 04:53 AM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2004
Posts: 2,942 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 9 h 49 m 28 sec
Reputation Power: 62
How about posting the code you've got so far?

MK

Reply With Quote
  #3  
Old September 20th, 2004, 10:55 AM
Chowyunli Chowyunli is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 4 Chowyunli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Here are the 2 functions I've got so far:

<% option Explicit

if (session("Interested")= "Billing Questions")then
Response.Redirect("billingcontact.asp")
end if

if (session("Interested") = "Need Instructions") or (session("Interested") = "Website Issues") or (session("Interested") = "Verification Issues/Questions") or (session("Interested") = "Account Questions") or (session("Interested") = "Employer Search Issues") or (session("Interested") = "Pricing") or (session("Interested") = "New Account Set Up") or (session("Interested") = "Credit Card Issues") or (session("Interested") = "Other") Then
Response.Redirect("contact.asp")
End If
%>

function direct()
if (session("Interested")= "Billing Questions")
{
{
document.theForm.action = "billingcontact.asp";
}
else
{
document.theForm.action = "contact.asp"
}
return true;
}

Th 'onSubmit' event calls a function that validates the selection. I'd like to have both done at the same time i.e. the form validated and then the appropriate method chosen.

Thanks a lot!
Quote:
Originally Posted by selwonk
How about posting the code you've got so far?

MK

Reply With Quote
  #4  
Old September 20th, 2004, 11:05 AM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2004
Posts: 2,942 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 9 h 49 m 28 sec
Reputation Power: 62
Do you mean you want to get rid of the ASP server-side but and really on JavaScript that a) validates the FORM and b) changes the FORM's ACTION tag to point to the relevant page and SUBMITs the FORM?

MK

Reply With Quote
  #5  
Old September 20th, 2004, 11:21 AM
Chowyunli Chowyunli is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 4 Chowyunli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes, I'd like to have a javaScript function that calls the 'validation' function , and then changes the FORM's ACTION tag to point to the relevant page and SUBMITs the FORM.



Quote:
Originally Posted by selwonk
Do you mean you want to get rid of the ASP server-side but and really on JavaScript that a) validates the FORM and b) changes the FORM's ACTION tag to point to the relevant page and SUBMITs the FORM?

MK

Reply With Quote
  #6  
Old September 20th, 2004, 12:01 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2004
Posts: 2,942 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 9 h 49 m 28 sec
Reputation Power: 62
Ok

You obviously know what you're trying to do with validation etc. I'd suggest you research the JavaScript SWITCH function to simplify your programming

MK

Reply With Quote
  #7  
Old September 20th, 2004, 04:21 PM
Chowyunli Chowyunli is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 4 Chowyunli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,
> I must apologize if my description of the problem was not clear. What
I'm
trying to with this form when it is submitted is :
> 1) to have it validated - and that function's already been defined
and
works .
> 2) to redirect the user to an apropriate form based on the choice
that's
been made.
> So, I guess I need to create a function that redirects the user and
also
calls the other one. I've pasted a copy of the code and would be
immensely
grateful for your help!
> thanks,
>
>
> <% option Explicit
>
>
> if (session("Interested")= "Billing Questions")then
> Response.Redirect("billingcontact.asp")
> end if
>
> if (session("Interested") = "Need Instructions") or
(session("Interested")
= "Website Issues") or (session("Interested") = "Verification
Issues/Questions") or (session("Interested") = "Account Questions") or
(session("Interested") = "Employer Search Issues") or
(session("Interested")
= "Pricing") or (session("Interested") = "New Account Set Up") or
(session("Interested") = "Credit Card Issues") or
(session("Interested") =
"Other") Then
> Response.Redirect("contact.asp")
> End If
> %>
>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
>
> <script language="javascript">
> <!--
> function direct()
> if (session("Interested")= "Billing Questions")
> {
> {
> Response.Redirect("billingcontact.asp");
> isThisValid
> }
> else
> {
> Response.Redirect("contact.asp")
> }
> return true;
> }
>
> function isThisValid()
> {
> return validator(this)
> }
> -->
> </script>
>
>
>
> </head>
>
> <body leftmargin="5" topmargin="5" marginwidth="0" marginheight="0">
>
>
> <table border="0" width="100%" cellpadding="0" cellspacing="0">
> <tr>
> <td valign="top"><p>Choosing a question or subject from the list
below is
the the fastest way to get an answer.
> In fact, we can usually answer your question instantly.<br><br>
> Please pick a subject that relates to your question.
> </p>
> <form name="theForm" method="post" action="contact.asp"
onsubmit="return
validator(this)">
> <table width="100%" border="0" cellpadding="0" cellspacing="0">
>
>
> <tr><td width="40%" valign="top"><p>
> <select name="Interested" size="1">
> <option<%If session("Interested")="Select Subject" then %>
selected
<%end if%>>Select Subject</option>
> <option<%If session("Interested")="Pricing" then %> selected
<%end
if%>>Pricing</option>
> <option<%If session("Interested")="Billing Question" then %>
selected
<%end if%>>Billing Question</option>
> <option<%If session("Interested")="New Account Set Up" then %>
selected <%end if%>>New Account Set Up</option>
> <option<%If session("Interested")="Need Instructions" then %>
selected
<%end if%>>Need Instructions</option>
> <option<%If session("Interested")="Website Issues" then %>
selected
<%end if%>>Website Issues</option>
> <option<%If session("Interested")="Verification Issues/Questions"
then
%> selected <%end if%>>Verification Issues/Questions</option>
> <option<%If session("Interested")="Account Questions" then %>
selected
<%end if%>>Account Questions</option>
> <option<%If session("Interested")="Credit Card Questions" then %>
selected <%end if%>>Credit Card Questions</option>
> <option<%If session("Interested")="Employer Search Issues" then
%>
selected <%end if%>>Employer Search Issues</option>
> <option<%If session("Interested")="Other" then %> selected <%end
if%>>Other</option>
> </select>
> </p>
> <p align="right">
> <input name="Submit" type="submit" value="Submit">
> </p>
> <tr><td>&nbsp;</td><td width="18%">&nbsp;</td>
> <td width="42%">&nbsp;</td>
> </tr>
> </table></form>
> </td>
> </tr>
> </table>
-->
> </body>
> </html>

Reply With Quote
  #8  
Old September 20th, 2004, 04:59 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2004
Posts: 2,942 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 9 h 49 m 28 sec
Reputation Power: 62
This could be made simpler by adding validation markup to your input boxes and performing the validation on the page that you post to. For example:

Code:
<form method="post" action="val.asp">
<input type="text" name="Name_R">&nbsp;Name (required)<br>
<input type="text" name="Job_R">&nbsp;Job description (required)<br>
<input type="text" name="Phone"&nbsp;Phone number (optional)
</form>
Once this form is posted to a script you can validate it:
Code:
<%
str_Errors = ""
For Each str_ItemFound In Request.Form
If InStr(str_ItemFound,"_") <> 0 Then
ary_Rules = Split(str_ItemFound,"_")
Select Case ary_Rules(1)
Case "R" ' Required field
If Request.Form(str_ItemFound) = "" Then
str_Errors = str_Errors & "The " & str_ItemFound & " field must be completed"
End If
End Select
End If
Next
If str_Errors <> "" Then
Response.Write("<script language=""JavaScript"">" & vbcrlf)
Response.Write("alert('Please correct the errors on your form:\n\n" & str_Errors & "');" & vbcrlf)
Response.Write("history.back(0);" & vbcrlf)
Response.Write("</script>" & vbcrlf)
Response.End
End If
%>
That way you can reuse the validation loop for any number of fields just by adding the relevant "_R" (or whatever validation "tags" you choose to add)

You can also use the Select to simplify your redirection:
Code:
<%
Select Case Session("Interested")
Case "Need Instructions", "Website Issues", "Verification Issues/Question" ' etc.
str_Target = "contact.asp"
Case "Billing Questions"
str_Target = "billingcontact.asp"
Case Else
str_Target = "contact.asp"
End Select
Response.Redirect(str_Target)
%>
MK

Last edited by selwonk : September 20th, 2004 at 05:01 PM.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > How do I redirect a form


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 3 hosted by Hostway
Stay green...Green IT