ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 10th, 2003, 06:23 AM
jaybro jaybro is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 1 jaybro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation if statement problem

Problem:
I want the option selected when I change it in the <select>-box.
While the "currentCat"-variable is good (due to request.form), the "rs("CatID")" in the if-statement seems to be wrong. What am i doing wrong?
For preview: URL (dutch)

-------------------------------------------------------------
SQL = "SELECT * FROM categories WHERE status = 'YES' ORDER BY SortOrder, CatDesc ASC;"

Set rs = Server.CreateObject ("ADODB.Recordset")
rs.Open SQL, dbc, adOpenKeyset, adLockReadOnly

IF NOT rs.EOF THEN
%>
<form method="post" name="gocat" action="default.asp">
<td><select name="id" onchange="submit()">
<%
While Not rs.EOF
%><option value="<%=rs("CatID")%>"
<% IF rs("CatID") = currentCat THEN
%> selected <%
END IF %>
><%=rs("CatDesc")%></option><%
rs.MoveNext
WEND
%></select></td></form><%
ELSE
Response.Write("<FONT COLOR=RED>Error</FONT>")
END IF
------------------------------------------------------------

Reply With Quote
  #2  
Old July 10th, 2003, 05:49 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
Is your CurrentCat an integer? You may have to convert it into an integer, because it may think it's a string (for example, Cint(CurrentCat))

Can you give more info about the problem? I assume the drop down list is appearing? Does it just not show it as selected or are you getting an error msg?

Last edited by aspnewbie : July 10th, 2003 at 05:52 PM.

Reply With Quote
  #3  
Old July 11th, 2003, 12:01 PM
wes wes is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 24 wes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ASPnewbie is probably right on. When you retrieve form or querystring values, even if they are numbers they are treated as strings. I have to account for this situation often when dealing with forms.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > if statement problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway