PDA

View Full Version : Querystring Problem I Guess


Peterpan
01-03-2003, 01:39 PM
I got this menu on my web site that generate tabs on the fly mu problem is that I want the tab to becaome "on" when the querystring is = to the category in the database my probelm is from line 17 to 23 I do not get any error just the tab stay off



<center>
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>&nbsp;</td>
</tr>
<tr valign="bottom">
<td><a href="./"><img src="images/tab-home-on.gif" alt="Home" width="49" height="26" border="0"></a></td>
<%
dim NavRS
set NavRS = server.createobject("adodb.recordset")
NavRS.activeconnection = objc
NavRS.open "SELECT * FROM categories ORDER BY id"
do while not NavRS.EOF
dim id, IntID
id = NavRS.Fields("id")
IntID = Int(id)
if request.querystring("category") = IntID then %>
<td>&nbsp;</td>
<td><a href="product.asp?category=<%=id%>"><img src="images/tab-<%=id%>-on.gif" border="0"></a></td>
<% else %>
<td>&nbsp;</td>
<td><a href="product.asp?category=<%=id%>"><img src="images/tab-<%=id%>-off.gif" border="0"></a></td>
<% end if %>
<%
NavRS.movenext
loop
%>

<td>&nbsp;</td>
<td><a href="ebay.asp"><img src="images/tab-ebay-off.gif" alt="" width="55" height="26" border="0"></a></td>
</tr>
</table>
</center>
<%
NavRS.Close
Set NavRS = Nothing
%>

aCcodeMonkey
01-03-2003, 08:07 PM
peterpan,

I just strongly typed the variable to test and it works.

Example:


<%
dim NavRS
dim id, bDisplay
bDislay = False
set NavRS = server.createobject("adodb.recordset")
NavRS.activeconnection = objc
NavRS.open "SELECT * FROM categories ORDER BY id"
'Loop to Find a Match
do while not NavRS.EOF
id = NavRS.Fields("id").Value
' Strongly type the two variables
if (CInt(request.querystring("category")) = CInt(id)) then %>
<td>&nbsp;</td>
<td><a href="product.asp?category=<%=id%>"><img src="images/tab-<%=id%>-on.gif" border="0"></a>ON</td>
<% else %>
<td> </td>
<td><a href="product.asp?category=<%=id%>"><img src="images/tab-<%=id%>-off.gif" border="0"></a>OFF</td>
<% end if %>

NavRS.movenext
loop


Hope this helps :cool: