?
Solved

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

Posted on 2010-09-07
5
Medium Priority
?
284 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 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
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 add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Suggested Courses

862 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