[Javascript] Checkbox Problems

Paul Novitski paul at novitskisoftware.com
Mon Jul 4 20:36:06 CDT 2005


At 05:57 PM 7/4/2005, Timothy White wrote:
>So basically I can get the checked state of a checkbox with the
>checked attribute (node). I can also set the HTML attribute 'checked'
>so that when the page loads the checkbox is checked. But if I set the
>HTML attribute to checked, how can I remove it? Remember that it
>doesn't take a value, so setting it to false does nothing.


Tim,

I use an XHTML DOCTYPE in which the checked attribute is:

         ON:  checked="checked"
         OFF: checked=""

I can treat it as any other attribute/value pair, toggling the value and 
not the existence of the attribute itself.

I haven't tried this with regular HTML but you might want to see if that 
works with that DOCTYPE as well.

Paul 





More information about the Javascript mailing list