« Flash 7 on Mobile? Can't be... | ^ Main | Is it all hype? »


IE Bites: option disabled doesn't work

IE has once again bit the big one so I figured I’ll start posting my IE Bites messages here instead of IM’ing Cody or Mike and venting to them about IE. That is kinda like preaching to the choir. :-) Well, maybe not…the choir has issues too.

I’m working in IE 6 but forgot to test one piece of functionality before sending this site live. As usual, everything works great in Firefox so I had no idea there was even potential for an issue. Come to find out the disabled attribute for an option doesn’t work in IE. Here’s what I had to do.

function checkDisabledOptions(elem){
	if(elem.options[elem.options.selectedIndex].disabled){
		elem.selectedIndex = 0;
	}
}

This turned out to be invaluable. It basically doesn’t changes the selectedIndex of the dropdown to 0 if they select the disabled option. This works for us in this scenario but I can easily see where keeping track of the last selected index would be of value as well.

The HTML for interacting with this is the commonly used onChange event.

select name="mycombo" onChange="checkDisabledOptions(this);"

I added styles to the disabled option so it would show as light text and not black. Ultimately I’m not terribly bruised by this issue but it was quite annoying to have this bug come about at the end of the project (literally as we’re testing on the live server in a /beta folder).

I found out about this issue from a post on Alistair Lattimore’s blog. He has solutions and examples but I just took what I needed for this particular project.

Posted by John C. Bland II on February 22, 2006 1:52 AM |

TrackBack

TrackBack URL for this entry:
http://mt.katapultmedia.com/mt-tb.cgi/47

Post a comment