|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 ------------------------------------------------------------ |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > if statement problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|