Reputation: 29
I am showing Category and Sub category in a drop down box and I don't want the drop down value of the main category to be selected by any user.
So I applied disable="disabled"
and it works fine in Firefox, Chrome, and also IE8, but it is not working in IE6 and IE7.
my code:
<option value="test" disabled="disabled" >Test></option>
Upvotes: 2
Views: 3479
Reputation: 321
You can put "Category" and "Subcategory" into <optgroup>
like this:
<select>
<optgroup label="Category"></optgroup>
</select>
or
<select>
<optgroup label="Category">
<option>Category 1</option>
<option>Category 2</option>
</optgroup>
</select>
is supported in IE5.5
See http://reference.sitepoint.com/html/optgroup for details.
Upvotes: 0
Reputation: 22698
I don't think you can achive this in IE. What you can do is to use a little javascript to tell the user that the option is disabled:
function check(el) {
if (el.options[el.selectedIndex].disabled) {
alert ("This option is not available!")
el.options.value = '';
}
}
Also check this solution: http://www.lattimore.id.au/2005/07/01/select-option-disabled-and-the-javascript-solution/
Upvotes: 0
Reputation: 2053
It seems this is a well documented problem with IE6/IE7.
A quick Google search revealed this potential workaround: http://www.goodercode.com/wp/disable-select-options-internet-explorer-jquery/
Upvotes: 2