Print Page | Close Window

help req’d with combo box

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=7587
Printed Date: 31 March 2026 at 11:22pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: help req’d with combo box
Posted By: stevem2003
Subject: help req’d with combo box
Date Posted: 25 November 2003 at 6:53am

Hi,

I have the following code for a Combo box:-

<select name="accesslevel" class="form">
<option value="0" <% if Clng(rs("accesslevel"))=0 then Response.Write " selected" end if%>>View only</option> 
<option value="1" <% if Clng(rs("accesslevel"))=1 then Response.Write " selected" end if%>>Requestor</option>
<option value="2" <% if Clng(rs("accesslevel"))=2 then Response.Write " selected" end if%>>Yield</option>
<option value="3" <% if Clng(rs("accesslevel"))=3 then Response.Write " selected" end if%>>Authorise</option>
<option value="5" <% if Clng(rs("accesslevel"))=5 then Response.Write " selected" end if%>>Administrator</option>

</select>

However I can use this only for numbers (Clng) but how do I get it to work for letters.e.g. If the options were ABC etc?

TIA
Steve



-------------
There's no point running if you're on the wrong road!



Replies:
Posted By: MorningZ
Date Posted: 25 November 2003 at 7:31am

<select name="accesslevel" class="form">
<option value="0" <% if CStr(rs("accesslevel") & "")="0" then Response.Write(" selected") %>>View only</option> 
<option value="1" <% if CStr(rs("accesslevel") & "")="1" then Response.Write(" selected") %>>Requestor</option>
<option value="2" <% if CStr(rs("accesslevel") & "")="2" then Response.Write(" selected") %>>Yield</option>
<option value="3" <% if CStr(rs("accesslevel") & "")="3" then Response.Write(" selected") %>>Authorise</option>
<option value="5" <% if CStr(rs("accesslevel") & "")="5" then Response.Write(" selected") %>>Administrator</option>
<option value="A" <% if CStr(rs("accesslevel") & "")="A" then Response.Write(" selected") %>>Option A</option>
<option value="B" <% if CStr(rs("accesslevel") & "")="B" then Response.Write(" selected") %>>Option B</option>
</select>

the & "" in the Cstr statement protects againsts the database value being NULL.. (because if it was, the Cstr function would bomb)



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: stevem2003
Date Posted: 25 November 2003 at 9:07am
Many Thanks MorningZ

-------------
There's no point running if you're on the wrong road!



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