WEIGHT-10 Re: [Javascript] disabled menus
Peter Brunone
peter at brunone.com
Tue Mar 1 12:51:50 CST 2005
If you can't disable an option (it's possible that I could be wrong once this year), you might consider getting creative with the JS if you don't want to eliminate that option completely. For example, you could color the text or background differently, and then hook up the onchange event handler to a function. The function can check to see if the list is on a "forbidden" option, and then either (a) clear the selection or (b) re-select the previously-selected value.
FWIW...
Peter
From: Chuck Soper chucks at velofish.com
Thanks. I tried that and it didn't work either. I will take a totally
different approach. That is, I'll accept that it's not possible to
"disable individual options in a select element" as Peter Brunone
suggested.
Thanks for everyone's help.
Chuck
At 10:55 AM +0100 3/1/05, Hakan M (Backbase) wrote:
>I suppose it doesn't work in IE. For a slightly non-kosher solution,
>you could try
>
>element['disabled'] = 'disabled';
>
>Don't make a habit out of it. ;)
>
>Regards,
>H
>
>Chuck Soper wrote:
>>Paul,
>>
>>Thanks for your response.
>>
>>I added the following line to the popuplateBreadSelect function:
>> element.setAttribute("disabled", "disabled");
>>but, it doesn't work.
>>
>>I read the w3.org link and noticed the disabled attribute for the
>>Option Element states: unavailable in this context.
>>
>>Do you know how or if I can modify my code to get this to work? I
>>can disable the entire dropdown, but not individual elements.
>>source: http://www.velofish.com/menu/menuTest.js
>>
>>Chuck
>>
>>At 10:35 PM -0800 2/28/05, Paul Novitski wrote:
>>
>>>At 07:19 PM 2/28/2005, Chuck Soper wrote:
>>>
>>>>I'm trying to display disabled menu items.
>>>
>>>
>>>
>>>Chuck,
>>>
>>>To disable a select option, just add the "disabled" attribute to the tag:
>>>
>>>HTML: Banana
>>>XHTML: Banana
>>>
>>>The disabled option is greyed out and can't be selected.
>>>
>>>You can set this attribute with Javascript using code like this:
>>>
>>> oOption.setAttribute("disabled", "disabled");
>>>
>>>where oOption is the OPTION object.
>>>
>>>The disabled option is listed as an attribute of OPTION in the W3C
>>>HTML specification:
>>>
>>> The SELECT, OPTGROUP, and OPTION elements
>>> http://www.w3.org/TR/html4/interact/forms.html#h-17.6
>>>
>>>(scroll down to the OPTION section)
>>>
>>>Paul
>>
>>_______________________________________________
>>Javascript mailing list
>>Javascript at LaTech.edu
>>https://lists.LaTech.edu/mailman/listinfo/javascript
>>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20050301/d88f5946/attachment.htm>
More information about the Javascript
mailing list