|
-
October 17th, 2001, 10:25 AM
#1
my code not working properly :<
I'm using the code (below) to bring up the next form. This code is located on part10, the last part, of a 9part form. The variables are sent from part1.asp to part90.asp using:
<%
For Each thing In Request.Form
Response.Write "<input type=""hidden"" name=""" & thing & """ value=""" & Request.Form(thing) & """>" & vbCrLf
Next
%>
Why is the determineForm always going to "thankyou" ???
Can someone look at this, to help me out, thanks ahead of time!:
<%
Function determineForm()
amount_of_money_brought = Request.Form("amount_of_money_brought")
number_of_dependents = CInt(Request.Form("number_of_dependents"))
applicants_birth_year = CInt(Request.Form("applicants_birth_year"))
age_factor = CInt(Request.form("age_factor"))
education_training_factor = CInt(Request.Form("education_training_factor"))
occupation_factor = CInt(Request.Form("occupation_factor"))
education_factor = CInt(Request.Form("education_factor"))
relatives_in_Canada = CInt(Request.Form("relatives_in_Canada"))
spouse_occupational_demand_factor = CInt(Request.Form("spouse_occupational_demand_factor"))
work_experience_factor = CInt(Request.Form ("work_experience_factor"))
business_experience = CInt(Request.Form("business_experience"))
destination_province = CInt((Request.Form("destination_province")))
net_worth = CInt(Request.Form("net_worth"))
Dim i
For i = 1 to 8
If Request.Form("D" & i) = 1 Then
determineForm = "Thankyou" : Exit Function
Next
If amount_of_money_brought = 1 OR age_factor = 0 OR destination_province = 6 OR applicants_birth_year = 0 Then
determineForm = "Thankyou" : Exit Function
End If
If (number_of_dependents + amount_of_money_brought) < (25000 + number_of_dependents) Then
determineForm = "Thankyou" : Exit Function
End If
applicant_speaks_english = CInt(Request.Form("applicant_speaks_english"))
applicant_reads_english = CInt(Request.Form("applicant_reads_english"))
applicant_writes_english = CInt(Request.Form("applicant_writes_english"))
applicant_speaks_french = CInt(Request.Form("applicant_speaks_french"))
applicant_reads_french = CInt(Request.Form("applicant_reads_french"))
applicant_writes_french = CInt(Request.Form("applicant_writes_french"))
iTempTotal = applicant_speaks_english + applicant_reads_english + applicant_writes_english + applicant_speaks_french + applicant_reads_french + applicant_writes_french
If iTempTotal < 1 Then iSumTotal = 0
If iTempTotal > 1 AND iTempTotal < 6 Then
iSumTotal = 2
Else
iSumTotal = iTempTotal
End If
iSumTotal = iTempTotal + age_factor + work_experience_factor + occupation_factor + education_factor + relatives_in_Canada + education_training_factor
If iSumTotal >= 60 Then
If net_worth = 0 OR net_worth = 1 Then
determineForm = "SkilledworkerFederalbusinessform" : Exit Function
Else
determineForm = "SkilledworkerFederal" : Exit Function
End If
Else
iSumTotal = iTempTotal + age_factor + work_experience_factor + education_factor + spouse_occupational_demand_factor + education_training_factor
If iSumTotal >= 35 Then
Select Case spouse_occupational_demand_factor
Case 98 determineForm = "skilledworkerAB" : Exit Function
Case 97 determineForm = "skilledworkerSK" : Exit Function
Case 96 determineForm = "skilledworkerMB" : Exit Function
Case 95 determineForm = "skilledworkerNB" : Exit Function
Case 94 determineForm = "skilledworkerNFL" : Exit Function
End Select
Select Case education_training_factor
Case 98 determineForm = "skilledworkerAB" : Exit Function
Case 97 determineForm = "skilledworkerSK" : Exit Function
Case 96 determineForm = "skilledworkerMB" : Exit Function
Case 95 determineForm = "skilledworkerNB" : Exit Function
Case 94 determineForm = "skilledworkerNFL" : Exit Function
End Select
iLastTwo = 45
Select Case spouse_occupational_demand_factor
Case 6.01 determineForm = "skilledworkerAB" : Exit Function
Case 8.01 determineForm = "skilledworkerAB" : Exit Function
Case 6.02 determineForm = "skilledworkerMB" : Exit Function
Case 4.02 determineForm = "skilledworkerMB" : Exit Function
Case 2.02 determineForm = "skilledworkerMB" : Exit Function
Case 8.02 determineForm = "skilledworkerMB" : Exit Function
Case 4.03 determineForm = "skilledworkerNB" : Exit Function
Case 8.03 determineForm = "skilledworkerNB" : Exit Function
Case 6.03 determineForm = "skilledworkerNB" : Exit Function
End Select
End If
If iSumTotal < 35 Then
iSumTotal = iTempTotal + age_factor + education_factor + education_training_factor + business_experience
If iSumTotal >= 17 Then
If net_worth = 1 Then determineForm = "InvestorEntrepreneur" : Exit Function
If net_worth = 0 AND investment_into_business = 1 Then
If business_experience = 6 OR business_experience = 8 Then
determineForm = "Entrepreneur" : Exit Function
End If
End If
Else
determineForm = "Thankyou" : Exit Function
End If
End If
End If
End Function
%>
<html>
<head>
<title>Conditional Form Example</title>
</head>
<body>
<%Select Case LCase(determineForm())
Case "thankyou"%>
<p align="center">Thanks for applying. Unfortunately, you don't qualify.</p>
<%Case "Skilledworkerfederalbusinessform"%>
<form name="part2-11" method="POST" action="nextpage1.asp">
<p><input type="text" name="T1" size="20"><input type="submit" value="Submit"></p>
</form>
<%Case "Skilledworkerfederal"%>
<form name="part2-12" method="POST" action="nextpage2.asp">
<p><input type="text" name="T1" size="20"><input type="submit" value="Submit"></p>
</form>
<%Case "skilledworkerAB"%>
<form name="part2-13" method="POST" action="nextpage3.asp">
<p><input type="text" name="T1" size="20"><input type="submit" value="Submit"></p>
</form>
<%Case "skilledworkerSK"%>
<form name="part2-14" method="POST" action="nextpage4.asp">
<p><input type="text" name="T1" size="20"><input type="submit" value="Submit"></p>
</form>
<%Case "skilledworkerMB"%>
<form name="part2-15" method="POST" action="nextpage5.asp">
<p><input type="text" name="T1" size="20"><input type="submit" value="Submit"></p>
</form>
<%Case "skilledworkerNB"%>
<form name="part2-16" method="POST" action="nextpage6.asp">
<p><input type="text" name="T1" size="20"><input type="submit" value="Submit"></p>
</form>
<%Case "skilledworkerNFL"%>
<form name="part2-17" method="POST" action="nextpage7.asp">
<p><input type="text" name="T1" size="20"><input type="submit" value="Submit"></p>
</form>
<%Case Else%>
<p align="center">Something went wrong. You may not have completed the form, </p>
<%End Select%>
</body>
</html>
-
October 18th, 2001, 02:00 PM
#2
Re: my code not working properly :<
I'm not sure, but I'm thinking your first if statement is causing the problem.
If Request.Form("D" & i) = 1 Then
determineForm = "Thankyou" : Exit Function
Next
("D" & i) might be "D 1" where a space in inserted infront of the number. You may want to say:
If Request.Form("D" & Trim(Str(i))) = 1 Then......
If this fixes it or not, I would add a redirect to a controlled page after the first if statement. Example:
If Request.Form("D" & i) = 1 Then
determineForm = "Thankyou" : Exit Function
Next
determineForm = "ControlBreak" : Exit Function
next statement here.....
As you run the code, if you make it to the Control Break page, you know that everything above worked as designed. Once tested, move the control break down, past the next condition and retest the page. After all conditions have been tested, remove the control break page.
Hope this helps.
TB_Guy_2000
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|