Solved

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

Posted on 2010-09-07
5
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

726 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