Link to home
Start Free TrialLog in
Avatar of Richardetal
RichardetalFlag for United States of America

asked on

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

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?
Avatar of pvlier
pvlier
Flag of Netherlands image

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>
Hi,

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

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


Avatar of Richardetal

ASKER

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.

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";
    }
  }
}
ASKER CERTIFIED SOLUTION
Avatar of sqlgang
sqlgang

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial