views:

246

answers:

2

I have a select box with 4 values (a,b,c,d). I just want to disable 'c' inside the dropdown. I used disabled property, it is working in all browsers but not in IE6.

I want to make it work on IE6. Could you give me some fix for this issue.

thanks

A: 

Unfortunately, I don't think it is possible. The work-around I've used in the past was to set the color of options that should be disabled to grey, and if one of those options were selected, I'd deselect it immediately using onchange().

rick
I'll assume the down-vote was due to the js dependency. Sometimes that isn't an issue (private/intranet business systems). Otherwise, the user could be shown the disabled options only if js is enabled.
rick
Javascript is the only option. +1 back to 0
naugtur
+2  A: 

The disabled attribute for the option element is completely unsupported by any version of Internet Explorer.

This page explains it: http://www.w3schools.com/TAGS/att_option_disabled.asp

In order to develop a proper workaround for IE, you need to explain your situation in how the select menu is being used. Using the onchange() function is not recommended because that implies requires the user actually have JavaScript enabled in order for it to work. The easiest thing to do would be to just completely remove that option from the select menu if you don't want anyone to select it. You should not be using the disabled attribute at all. It's simple: if you don't want someone to select it, don't put it in the list.

animuson
If you know the user has js enabled, or if you take the time to check first, then there is no issue.
rick
There is no efficient way to check if the user has JavaScript enabled, there is only the noscript element that displays if they do not. Every way I've seen that 'attempts' to detect if JavaScript is enabled is not 100% efficient.
animuson
ie8 rc2 brought the support. 10 Years after it was specified in standards.
naugtur