Select Categories Below
Advertisement
Start Your Own Q&A Site
Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.
Status: Closed Points: 125 Time: 04:33 - Jan 16, 2008
david
I'm populating a listbox dynamically with javascript and I need to make one option bold. In javascript I'm setting: option.style.fontWeight = 'bold'; before I add it to the listbox, but it only shows bold in Firefox. How can I achieve this in IE6 and IE7 as well?
Categories:
Add Categories
When adding more than one category, separate them with commas.
Date:: Jan 16, 2008
Time:: 05:00
i found another way to set this, but it doesn't work in IE either: option.style.cssText += "font-weight: bold"; :(
rcastagna
Date:: Jan 17, 2008
Time:: 08:53
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
Date:: Jan 18, 2008
Time:: 04:19
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.
Time:: 07:37
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
Date:: Jan 21, 2008
Time:: 10:26
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.
Question Answered
This question has been closed, 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 a Tutorial in the Tutorial Area.
Answer this Question
New User
Email:
Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address
Registered User
Username:
Password:
Forgot Your Password?
Enter your email address below and we will resend your login information to you.
Login Information Sent
sudhishnair
Date:: Apr 24, 2008
Time:: 03:52
i am new to javascript .... i am facing the same problem . i am trying to get the text in a table cell to bolden on the load event of the form using javascript document.getElementById("conf").style .fontWeight ="bolder"; document.getElementById("conf").style .color ="black"; where conf is the id of the "td" tag in the table.....works in FF but not in IE.
Click here to see the Answer Discussion that preceded this tutorial.
Login to rate this tutorial: Good | Bad
Questions
whats the best food to eat during midnight?
How to identify the tiffany jewelry? www.tffanycheapmall.com.
Send an email alert to each user of the php application based on criteria
How I Increased My AdSense Earnings?
how to choose the lady dress ?
How can I fulfill the minimum requirement to make your computer support 3D?
You have 100 characters to use
Rank
Expert
Points
1.
10354
2.
6493
3.
5596
4.
4848
5.
3487
6.
2840
7.
2770
8.
2303
9.
1820
10.
917
Register today to share your knowledge with the community and be recognized and rewarded for your contributions.
Register Here
"Psst, Quomon is a great site. Pass it on." Tell a Friend | Link To Us | Save to Delicious | Digg it
Language Options
English:
Español:
Sponsors
Questions and Answers Software