
Why does IE (IE8, specifically) not highlight selected option in a multi select box which is disable
Question:
I am having a multi select box in a JSP page which has some options and is disabled.
<select id="mySelectBox" multiple disabled>
<option value="first" selected>First</option>
<option value="second">Second</option>
<option value="third">Third</option>
<option value="fourth" selected>Fourth</option>
</select>
I have the first and the fourth options selected, but they are not highlighted in IE They are properly highlighted when I use Firefox.
Is there any solution or workaround for this?
<strong>EDIT:</strong> My DOCTYPE is <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
But even with that I don't see any difference.
I hope i clearly understand what you want to do, but i can sugest to do it with little jquery?
<script type="text/javascript">
$(document).ready(function() {
$("#mySelectBox option:selected").css('background','black');
});
</script>
Answer2:Interestingly, <a href="http://www.jefclaes.be/2010/02/ie8-fix-disabled-select-not-showing.html" rel="nofollow">this</a> CSS workaround seems to have fixed my issue!!
select[disabled="disabled"][multiple="multiple"]{
background-color:#D4D0C8;
}
select[disabled="disabled"][multiple="multiple"] option[selected="selected"]{
background-color:navy;
}
Interesting because, earlier I had used the same to no effect. Perhaps I had missed out on something then.