Forums
This topic is locked
Advanced formating of a dynamic drop down menu
Posted 09 Aug 2004 09:14:28
1
has voted
09 Aug 2004 09:14:28 Conrad Cranfield posted:
Hi there,I have a dynamic drop down menu (a form drop down menu) which is populated with a recordset that displays variations of a product (ie: the different sizes and colors). I have set the class of the drop down menu (using css), however I want to be able to dynamically set the color of the lines in the drop down menu if a condition is met (ie: the variation is on special). Is this possible? I have tried using span classes and <font color> tags embedded in a conditional clause, but with no luck.
Any suggestions here much appreciated. PS: I am using asp vbscript
Cheers
Conrad
Replies
Replied 18 Sep 2004 00:38:46
18 Sep 2004 00:38:46 Dan Berdusco replied:
Hey snowconrad,
This is very poossible. You can actually add classes to each specific option in your dropdown menu. Add in a few if/then statements with a css file and you are all set. Something like this:
<pre id=code><font face=courier size=2 id=code> <select name="select">
<%
While (NOT RS_Name.EOF)
%>
<option value="<%=(RS_Name.Fields.Item("fieldnameValue"
.Value)%>" <%If (RS_Name.Fields.Item("fieldname2"
.Value) <> 1 Then %>
class="BlueText"
<% End If %>
<%If (RS_Name.Fields.Item("fieldname2"
.Value) = 1 Then %>
class="GreenText"
<% End If %>><%=(RS_Name.Fields.Item("fieldnameLabel"
.Value)%></option>
<%
RS_Name.MoveNext()
Wend
If (RS_Name.CursorType > 0) Then
RS_Name.MoveFirst
Else
RS_Name.Requery
End If
%>
</select></font id=code></pre id=code>
Obviously you will have to change some stuff in there... The if statements check the value of a certain field. I have it setup so that if the value is equal to 1 then it will use the bluetext style. If it is equal to something other than 1, then use the greentext style. You can add as many if statements as you need.
Does that help?
Edited by - flexman44 on 18 Sep 2004 00:40:01
This is very poossible. You can actually add classes to each specific option in your dropdown menu. Add in a few if/then statements with a css file and you are all set. Something like this:
<pre id=code><font face=courier size=2 id=code> <select name="select">
<%
While (NOT RS_Name.EOF)
%>
<option value="<%=(RS_Name.Fields.Item("fieldnameValue"


class="BlueText"
<% End If %>
<%If (RS_Name.Fields.Item("fieldname2"

class="GreenText"
<% End If %>><%=(RS_Name.Fields.Item("fieldnameLabel"

<%
RS_Name.MoveNext()
Wend
If (RS_Name.CursorType > 0) Then
RS_Name.MoveFirst
Else
RS_Name.Requery
End If
%>
</select></font id=code></pre id=code>
Obviously you will have to change some stuff in there... The if statements check the value of a certain field. I have it setup so that if the value is equal to 1 then it will use the bluetext style. If it is equal to something other than 1, then use the greentext style. You can add as many if statements as you need.
Does that help?
Edited by - flexman44 on 18 Sep 2004 00:40:01