Solved

Text color of option element works in Firefox, Chrome, Safari but not IE8

Posted on 2010-09-07
5
257 Views
Last Modified: 2012-05-10
I wanted to change the font color of disabled drop down options for a calendar dated picker.  I used the following code:

daysOfMonth.options[28].style.color = "red";

which works fine everywhere but in IE8 (not sure about earlier versions of IE).

Any suggestions?
0
Comment
Question by:Richardetal
5 Comments
 
LVL 8

Expert Comment

by:pvlier
ID: 33619541
How about using css:
<head>
<STYLE type="text/css">
OPTION.mar{background-color:maroon; color:white}
OPTION.white{background-color:white; color:maroon}
</STYLE>
</head>
<body>
<FORM>
<SELECT>
<OPTION>What is your preferred browser?</OPTION>
<OPTION class="mar">Firefox</OPTION>
<OPTION class="white">Internet Explorer</OPTION>
</SELECT>
</FORM>
</body>
0
 
LVL 15

Expert Comment

by:Insoftservice
ID: 33619984
Hi,

where id = 0 to 28
                  $('DDiv_'+id).className = "translucent";

where DDiv is ur id of ur select option.
                  $('DDiv_'+id).style.color = "#EE8404";


0
 

Author Comment

by:Richardetal
ID: 33620155
These dates are being disabled dynamically so I can't use CSS as you suggest pvlier.  

insoftservice: your suggestion appears to be what I have done already.  It seems to me that IE doesn't know what to do with the .style.color.  I've tried "#FF0000" instead of "red" but that didn't work either.

0
 

Author Comment

by:Richardetal
ID: 33620195
Here is the weekend function which works in everything but IE.

function remove_weekends(month_id_name,year_id_name) {
    for (int_day=1; int_day<=31; int_day++){
    var day = document.getElementById(month_id_name).value + "/" + int_day  + "/" + document.getElementById(year_id_name).value ;
  var d=new Date(day);
    var dow=d.getDay(day);
    if (dow==0 || dow==6){
      daysOfMonth.options[int_day-1].disabled = true;
      daysOfMonth.options[int_day-1].style.color = "#ff0000";
    }
  }
}
0
 
LVL 2

Accepted Solution

by:
sqlgang earned 250 total points
ID: 33629232
There is no way to change disabled select element's color from gray to something else. This is IE's default and non w3c standard - behaviour. So, just have to accept that its not going to happen in IE.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now