Home > Archive > ASP > May 2006 > Multiple colors on <select> list
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Multiple colors on <select> list
|
|
|
|
Is it possible to make a select list item red based on a condition ?
TIA,
PW
| |
| Mike Brind 2006-05-30, 7:55 am |
|
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
| |
|
|
"Mike Brind" <paxtonend@hotmail.com> wrote in message
news:1148989955.289380.103710@g10g2000cwb.googlegroups.com...
>
> PW wrote:
>
> 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
|
|
|
|
|