|
i found another way to set this, but it doesn't work in IE either:
option.style.cssText += "font-weight: bold";
:(
|
|
Expert:
|
david
|
|
Date:
|
Jan 16, 2008
|
|
Time:
|
05:00
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
David,
From what I can remember, this reason behind this is because of how IE gets the "base" for the HTML Select tag - it's derived from the Win32api - the same reason why dropdownlists and select lists have a nasty habit of rendering "above" everything else on the html page.
I tried the simple example code of :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-t...
<html xmlns=" http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css" media="screen">
.optionBold {background-color: Fuchsia; font-weight: bold;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<select id="htmlSelect" multiple="multiple" size="5" >
<option>Non-styled 1</option>
<option>Non-styled 2</option>
<option class="optionBold">Styled</option>
<option style="background-color: Aqua; font-weight: bold;">Styled inline</option>
</select>
</div>
</form>
</body>
</html>
In both styling cases, I would see them fine in Firefox, but only the background color was being picked up for the options in IE.
Now, if you feel like being really adventurous, you can check out a workaround presented by Scott Mitchell over here: http://aspnet.4guysfromrolla.com/article...
I hope this helps,
Ric
|
|
Expert:
|
rcastagna
|
|
Date:
|
Jan 17, 2008
|
|
Time:
|
08:53
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
thanks for the response, Ric, I didnt know the reason for the dropdown issues in IE.
The article didn't really help me out since it's talking about a workaround for a bug in asp.net and I'm just using plain javascript and html, and the problem is beyond the control of asp.net.
|
|
Expert:
|
david
|
|
Date:
|
Jan 18, 2008
|
|
Time:
|
04:19
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
David,
Well, you're right...it wouldn't help much if you're not using .NET for the page.
I did have another thought, though...you could make an unordered list <ul> "appear" to be a list box with some creative styling. Then you'd have all of your styling options available to you.
It might take some time to fuss around with, but it would certainly be possible. Granted, this isn't a "solution" to the problem in IE - but sadly, as long as IE continues to use the win32api for these two controls, they will always behave badly.
Take care,
Ric
|
|
Expert:
|
rcastagna
|
|
Date:
|
Jan 18, 2008
|
|
Time:
|
07:37
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
Ric, that could be a way to get round it, but I don't have time to experiment with it.
I just sorted to give the option an slightly different background color, which does work in both FF and IE and that will have to do for now.
Thanks for your help.
|
|
Expert:
|
david
|
|
Date:
|
Jan 21, 2008
|
|
Time:
|
10:26
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
|
|
|
|
This question has been answered, and points have been rewarded to the following experts:
You're welcome however to comment or give additional information or if you wish, you have the ability to write an Answer Summary for this question by clicking on the "Answer Summaries" Tab.
|
|