CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2001
    Posts
    6

    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:
    &lt;%
    For Each thing In Request.Form
    Response.Write "&lt;input type=""hidden"" name=""" & thing & """ value=""" & Request.Form(thing) & """&gt;" & vbCrLf
    Next
    %&gt;

    Why is the determineForm always going to "thankyou" ???
    Can someone look at this, to help me out, thanks ahead of time!:
    &lt;%
    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) &lt; (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 &lt; 1 Then iSumTotal = 0
    If iTempTotal &gt; 1 AND iTempTotal &lt; 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 &gt;= 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 &gt;= 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 &lt; 35 Then
    iSumTotal = iTempTotal + age_factor + education_factor + education_training_factor + business_experience
    If iSumTotal &gt;= 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
    %&gt;
    &lt;html&gt;
    &lt;head&gt;
    &lt;title&gt;Conditional Form Example&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;%Select Case LCase(determineForm())
    Case "thankyou"%&gt;
    &lt;p align="center"&gt;Thanks for applying. Unfortunately, you don't qualify.&lt;/p&gt;
    &lt;%Case "Skilledworkerfederalbusinessform"%&gt;
    &lt;form name="part2-11" method="POST" action="nextpage1.asp"&gt;
    &lt;p&gt;&lt;input type="text" name="T1" size="20"&gt;&lt;input type="submit" value="Submit"&gt;&lt;/p&gt;
    &lt;/form&gt;
    &lt;%Case "Skilledworkerfederal"%&gt;
    &lt;form name="part2-12" method="POST" action="nextpage2.asp"&gt;
    &lt;p&gt;&lt;input type="text" name="T1" size="20"&gt;&lt;input type="submit" value="Submit"&gt;&lt;/p&gt;
    &lt;/form&gt;
    &lt;%Case "skilledworkerAB"%&gt;
    &lt;form name="part2-13" method="POST" action="nextpage3.asp"&gt;
    &lt;p&gt;&lt;input type="text" name="T1" size="20"&gt;&lt;input type="submit" value="Submit"&gt;&lt;/p&gt;
    &lt;/form&gt;
    &lt;%Case "skilledworkerSK"%&gt;
    &lt;form name="part2-14" method="POST" action="nextpage4.asp"&gt;
    &lt;p&gt;&lt;input type="text" name="T1" size="20"&gt;&lt;input type="submit" value="Submit"&gt;&lt;/p&gt;
    &lt;/form&gt;
    &lt;%Case "skilledworkerMB"%&gt;
    &lt;form name="part2-15" method="POST" action="nextpage5.asp"&gt;
    &lt;p&gt;&lt;input type="text" name="T1" size="20"&gt;&lt;input type="submit" value="Submit"&gt;&lt;/p&gt;
    &lt;/form&gt;
    &lt;%Case "skilledworkerNB"%&gt;
    &lt;form name="part2-16" method="POST" action="nextpage6.asp"&gt;
    &lt;p&gt;&lt;input type="text" name="T1" size="20"&gt;&lt;input type="submit" value="Submit"&gt;&lt;/p&gt;
    &lt;/form&gt;
    &lt;%Case "skilledworkerNFL"%&gt;
    &lt;form name="part2-17" method="POST" action="nextpage7.asp"&gt;
    &lt;p&gt;&lt;input type="text" name="T1" size="20"&gt;&lt;input type="submit" value="Submit"&gt;&lt;/p&gt;
    &lt;/form&gt;
    &lt;%Case Else%&gt;
    &lt;p align="center"&gt;Something went wrong. You may not have completed the form, &lt;/p&gt;
    &lt;%End Select%&gt;
    &lt;/body&gt;
    &lt;/html&gt;



  2. #2
    Join Date
    Nov 2000
    Location
    Chicago
    Posts
    51

    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
  •  





Click Here to Expand Forum to Full Width

Featured