Multiple colors on <select> list

M

Mike Brind

PW said:
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.
 
P

PW

Mike Brind said:
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.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top