PDA

Click to See Complete Forum and Search --> : How to select the option?


JasonS
Nov 2nd, 2000, 12:19 PM
How can I set the selected option for a select object (dropdown list) based on the value in the database table?

This is how I'm populating my input boxes.

<input name="Fax" size="30" value="<%= trim(rs("tpFax")) %>">

How can I do that for a select object?

This is how I'm populating the select object.
<SELECT id=select1 name="Role_T2" size="1">
style="HEIGHT: 22px; WIDTH: 281px">
<OPTION value="1">Technical
<option value="2">Project Manager
</option></SELECT>

Thanks.

dadames
Nov 2nd, 2000, 01:07 PM
I use something like this...
<%
Dim strSelected
%>
<select name="cboDiscount" size="1" >
<%
If (some condition here) Then
strSelected = "Selected"
Else
strSelected = ""
End If
%>
<OPTION value="whatever" <% =strSelected %> > myLabel</OPTION>
</select>

Notice the <% =strSelected %> will have the value "Selected" when the condition is met.

Hope this helps.