Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Multiple colors on <select> list

Reply
Thread Tools

Multiple colors on <select> list

 
 
PW
Guest
Posts: n/a
 
      05-30-2006

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

TIA,
PW



 
Reply With Quote
 
 
 
 
Mike Brind
Guest
Posts: n/a
 
      05-30-2006

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

 
Reply With Quote
 
 
 
 
PW
Guest
Posts: n/a
 
      05-30-2006

"Mike Brind" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple foreground colors in AWT TextArea? Richard Maher Java 22 08-23-2009 03:38 AM
Is there any library that can convert RGB colors to ANSI colors? ZelluX Python 3 12-01-2008 11:08 AM
Newbie question about multiple colors in text Joe Todd HTML 6 09-10-2008 02:24 AM
TreeNode colors come from anchor colors AAaron123 ASP .Net 1 08-07-2008 07:56 PM
multiple colors in a single ProgressBar amit phalgune Java 3 02-04-2004 12:20 AM



Advertisments