Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare Querystring Value with Number

Status
Not open for further replies.

danieljoo

MIS
Oct 9, 2002
43
0
0
US
I have some asp that allows me to click on a CustomerName to see more detailed information about that Customer Grp. ie

CustomerNumber CustomerName Grp
1 Joes Store W23
2 Quick Stop
3 Joes Store #2 W23


if CustomerNumber 1 (or 3) is selected the link would return the following on the next page:

CustomerNumber City State
1 Detroit MI
3 Chicago IL

What I am trying to do on this page is <strong> the Customer Number that was selected to get this information so that it will stand out (seeing that 1 or 3 could have been selected to get the same output). But for some reason I am having a problem with my comparison:

<%myVar1=Request.Querystring(&quot;CustomerNumber&quot;)%>
<%
x_ID = rs(&quot;ID&quot;)
x_CustomerNumber = rs(&quot;CustomerNumber&quot;)
x_City = rs(&quot;City&quot;)
x_State = rs(&quot;State&quot;)

%>

<tr bgcolor=&quot;<%= bgcolor %>&quot;>
<td><font size=&quot;-1&quot;>
<% response.write ucase(x_ID) %> 
</font></td>
<td><font size=&quot;-1&quot;>
<% response.write x_CustomerNumber %> 
</font></td>
<td>
<% if MyVar1 = x_CustomerNumber then%>
<font size=&quot;-1&quot;><strong><% response.write ucase(x_CustomerName) %></strong></font>
<% else%>
<font size=&quot;-1&quot;><% response.write ucase(x_CustomerName) %></font> 
<%end if%>

I've tried response write on both x_CustomerNumber and MyVar1, they both get the same output, but MyVar1 = x_CustomerNumber doesn't work, please help
 
debug it
<%
response.write myVar1 & &quot; &quot; & x_CustomerNumber
%>

are they really *EQ ?? _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
sorry had to submit that pre finished.
I wanted to add spaces to that.
trim() the values. make certain they are the same data type _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
I tried this

<%response.write trim(myVar1) & &quot; &quot; & trim(x_CustomerNumber)%>

and

<%response.write myVar1 & &quot; &quot; & x_CustomerNumber%>

for both I got this (the first set should be equal):

1 1
1 3
 
Ooops, got it to work with the trim(). Thank you very much onpnt.
 
did you try the trim in the code though
example: if I do this
dim myVar1, x_CustomerNumber
x_CustomerNumber = 1
myVar1 = &quot; 1&quot;
if myVar1 = x_CustomerNumber then
response.write &quot;<strong>&quot;&x_CustomerNumber&&quot;</strong>&quot;
else
response.write x_CustomerNumber
end if
' my output is not a strong tag but if I do
if trim(CInt(myVar1)) = Trim(CInt(x_CustomerNumber)) then
response.write &quot;<strong>&quot;&x_CustomerNumber&&quot;</strong>&quot;
else
response.write x_CustomerNumber
end if
' my output is strong tag because I have taken out the possiblility of a space which
' would lead to a value not equal and the data type ahs been changed to the same
' even knwoing in this case not needed, but for this example used
_________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
sorry posted at the same time I guess. glad you got it. remember trim and data type is a biggy in debugging these
[thumbsup2] _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top