Print Page | Close Window

check the value in two variables

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=26433
Printed Date: 29 March 2026 at 9:21am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: check the value in two variables
Posted By: William Rendell
Subject: check the value in two variables
Date Posted: 23 October 2008 at 9:25am
Hello
 
I am wondering if anyone can help me?
 
here is the code I am trying to get to work
 
<% if session("rn") = request.form("code") then
response.write("match")
else
response.write("no match")
end if %>
 
Both session("rn") and request.form("code") contain a number, what I am trying to achieve is if the two equal each other then it writes "match" if they dont equal the same then write no match.
 
My trouble is I never get a match even when I know both session("rn") and request.form("code") contain the same number! I have verified this by writing out them both on screen and can confirm they are the same, what am I doing wrong?
 
Thanks in advance
 
 
Will



Replies:
Posted By: socialanimal
Date Posted: 23 October 2008 at 5:37pm
Try wrapping cInt() round the variables to force them as integers. When bringing back from a request form variable, values are generally treated as strings.  


Posted By: shakir
Date Posted: 31 December 2008 at 2:19pm
<% if cint(session("rn")) = cint(request.form("code")) then
response.write("match")
else
response.write("no match")
end if %>

will work



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net