HTML/ASP Form Trouble

Posted on 2012-09-10
Last Modified: 2012-09-10

I have a form on an asp page (Showcaptive.asp), that creates two random numbers for a poor man's 'Captiva' validation, but when I get to the Captiva.asp page I can show both numbers but the if statement still say they're different.  

[showcaptiva.asp] (just the form)

<form action="Captiva.asp" method="get" class="style1">
      <p class="style2">Your Name<br>
<input name="EmailFrom" type="text" size="70">
<p class="style2">Your Email Address<br>
<input name="EmailTo" type="text" size="70">
<p class="style2">Subject<br>
<input name="Subject" type="text" size="70">
<p class="style2">Message<br>
<textarea name="Message" cols="70"></textarea>
dim RNDNumber1
dim RNDNumber2
RNDNumber1 = round(rnd*10)
RNDNumber2 = round(rnd*10)
'response.write("<BR>" & RNDNumber1 & "<BR>" & RNDNumber2 & "<BR>")
session("Result") = RNDNumber1+RNDNumber2


<p class="style2">In an effort to limit spam, please calculate the result of the two numbers below:<br>
<%=RNDNumber1 & " + " & RNDNumber2 & " = "%><input name="Captiva" type="text" size="20">

<p><input type="submit" name="submit" value="Submit">


In the asp page below I show no1 and no2 and they are identical, but the if statement never comes past the "Sorry that was not the correct result...


no1 = request("Captiva")
no2 = session("Result")

response.write("-->" & no1 & "<--" & "<br>" & "-->" & no2 & "<--<BR>")
      if no1 <> no2 then
            response.write("Sorry that was not the correct result, please go back and try again!")      
' do what I'm supposed to do...
Question by:prosit
    LVL 18

    Accepted Solution

    When the page posts, everything is turned into "strings".
    Since the "Result" was calculated using numbers, it is still a "number".
    Wrap a "cint" around the answer to make sure things are numbers.
    no1 = cInt(request("Captiva"))
    no2 = session("Result")

    Open in new window

    or, here:
    if cInt(no1) <> no2 then

    Open in new window

    LVL 2

    Author Closing Comment

    Knew it was simple :)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
    In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now