By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,727 Members | 766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,727 IT Pros & Developers. It's quick & easy.

Multiple colors on <select> list

P: n/a
PW

Is it possible to make a select list item red based on a condition ?

TIA,
PW

May 30 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

PW wrote:
Is it possible to make a select list item red based on a condition ?

TIA,
PW


Are you asking whether one can apply different styles to items in a
select list, or how to code conditional statements with server-side
code?

If the first, try googling optgroup and css, and see if this answers
your question. If it doesn't, you would be better off asking in a css
or stylesheet group.

If it's the second (although I suspect not) show the code you've tried,
and explain where it fails.

--
Mike Brind

May 30 '06 #2

P: n/a
PW

"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...

PW wrote:
Is it possible to make a select list item red based on a condition ?

TIA,
PW


Are you asking whether one can apply different styles to items in a
select list, or how to code conditional statements with server-side
code?

If the first, try googling optgroup and css, and see if this answers
your question. If it doesn't, you would be better off asking in a css
or stylesheet group.

If it's the second (although I suspect not) show the code you've tried,
and explain where it fails.

--
Mike Brind


Hi Mike,

Thanks for your response. I have since googled and found an answer.

I've created the css as suggested ...

<head>
<STYLE type="text/css">
OPTION.red{background-color:white; color:red}
OPTION.black{background-color:white; color:black}
</STYLE>
</head>

I then created a string based on the condition ...

if len(rs1("NOTES")) > 0 then
myOptionText = " class=red "
else
myOptionText = " class=black "
end if

And then concatenated the string into the <option> statement based on the
condition ...

if mySearchString <> "" then
if rs1("ESCI") = mySearchString then
response.write "<option selected " & myOptionText & ">"
else
response.write "<option " & myOptionText & ">"
end if
elseif rs1("ESCI") = left(myQueryString,6) then
response.write "<option selected " & myOptionText & ">"
else
response.write "<option " & myOptionText & ">"
end if
Thanks,
PW

May 30 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.