tshad wrote:
Quote:
I am trying to disable and enable a checkbox from javascript.
>
The problem is that if the checkbox starts out as:
>
<input id="Override" type="checkbox" name="Override"/>
>
I can change it back and forth with no problems.
using disabled = true or disabled = false
>
If I start out as:
>
<input id="Override" type="checkbox" name="Override" disabled="disabled"/>
>
I can never enable it again using the above statements.
>
I found a description of disabled as:
************************************************** *********************
disabled
Type: boolean
>
Indicates whether the checkbox is disabled or not. If this attribute is set
to true, the checkbox is disabled. This is usually drawn with the text in
grey. If the checkbox is disabled, it does not respond to user actions. The
element cannot be focused and the command event will not fire. The element
will still respond to mouse events. To enable the checkbox, leave the
attribute out entirely as opposed to setting the value to false.
************************************************** *******************************
>
How do you take the disabled attribute out using Javascript?
>
Is there some other way to make this work?
>
I don't have the same problem with a textbox. If it is set a
disabled="disabled", I can still enable and disable at will.
>
Thanks,
>
Tom
>
>
Try
myCheckBox.removeAttribute("disabled");
to get rid of the disabled attribute entirely. I think the fact that
you've set it to a value (in order to be XHTML compliant) has messed
with the DOM's mind - now, no matter what you set it to, the DOM thinks
the "disabled" attribute is there and will always show a disabled check
box. Removing the attribute might help.
I also suspect that if you served up your content as
application/xml+xhtml it would work as expected (except in IE).
Jeremy