Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Font color in SELECT OPTION

Status
Not open for further replies.

Glowball

Programmer
Oct 6, 2001
373
US
Hi all, can't seem to find this via a search though I'm sure it's been answered. How can I color some text in a select box option? Something like this (though this doesn't work):
Code:
<form>
<select name=&quot;something&quot; size=1>
<option value=&quot;&quot;>something goes <span style=&quot;color:red&quot;>here</span></option>
</select>
</form>
I just want the word &quot;here&quot; to be red if that's possible.

TIA!
 
Try this site,

(scroll to the bottom)

It only works for IE and you need to add some of his javasript files.

But in the example I saw a line:

optionArray[1] = new Option(&quot;Item <b>2</b>&quot;, &quot;value 2&quot;);

Maybe this will work :
optionArray[1] = new Option(&quot;Item <font color=red>2</font>&quot;, &quot;value 2&quot;);

Hope this helps,
Erik
 
Nope, that one won't catch either... I tried the following code but it writes it to the option instead:
Code:
<form name=&quot;thisForm&quot;>
<select name=&quot;something&quot; size=1>
<option value=&quot;&quot;>something goes <span style=&quot;color:red&quot;>here</span></option>
</select>
</form>
<script language=&quot;javascript&quot;>
var thisOption = new Option(&quot;something else goes <font color='red'>here</font>&quot;, &quot;&quot;);
thisForm.something.options[1] = thisOption;
</script>
Any other thoughts?
 
OK Glowball.. Take a look at this thread. I was intrigued by this and tested it in IE 5 and NS 6 and it worked in both. Although this thread discusses changing the background color of a single option in a select list, I'm wondering if you can tweek it a little to change the font color of a single option in a select list..

thread216-156170

(Still trying to recover from that painful correction you made to my other thread !!) :p

ToddWW
 
Aww Todd it's all in fun! It's just SO easy to get me back, so please feel free. Seriously, I need someone to call me on all this stuff I'm spouting... *laugh*

I've been successful with changing the entire OPTION text, but not with changing a piece of it. I don't see how to change a piece of it without surrounding that piece with some sort of tag (HTML, CSS, etc.). I haven't been successful with getting it to recognize a tag within OPTION text. Maybe that's not possible? I'm wondering if text between opening and closing OPTION tags is off limits...

And if it makes you feel any better, you're the only one I tease! If the coding wasn't fun we wouldn't be doing it, right?
 
Ohh, I see !! You want to chop up a portion of the option text and do some fancy formatting to it..

If I only spent the time to read the entire thread, I would have figured that out already..

I have two options here..

#1: Spend the rest of the night trying to figure out a backdoor solution to this..

#2: Have another beer and try to figure out how the Yankees could have possibly pulled off that bottom of the 10th inning victory over the DiamondBacks tonight when they were down 3-1 in the bottom of the 9th with 2 outs!!

Ummm... I'm leaning towards #2 right now.. LOL

ToddWW
 
Ummm... I think I ruined this thread for you.. You better post a new one !!

ToddWW
 
fil·i·bus·ter
The use of obstructionist tactics, especially prolonged speechmaking, for the purpose of delaying responsive action.

:)
ToddWW
 
*swiping Todd's dictionary and hiding it indefinitely*

#1 -- going to bed, &quot;rest of the night&quot; is officially over

#2 -- baseball? puhleeze... *yawn*

#3 -- wait for you to find the answer for me because you've ruined this thread for me (I have it in writing, I'll have my lawyer contact your lawyer)

I'm going with #3 it's so much more interesting! *laughing, falling out of chair, injuring self*
 
He may have ruined the thread for you, but it's certainly become and entertaining one for the rest of us. (hint to Todd: Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Yes, thank you Tracy.. However, my plagiarizing comes from
pla·gia·rize
To use and pass off (the ideas or writings of another) as one's own.

Really, this could go on forever.. :)
 
te·dious
tiresome because of length or dullness : BORING

Just kidding! :-0 Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top