[Javascript] IE work-a-round question (re: checkboxes)

David Dorward david at dorward.me.uk
Sat Apr 12 10:19:03 CDT 2008


On 12 Apr 2008, at 15:36, Paul Novitski wrote:
>
> Tedd, your code above (...id[2] + id[3]...) indicates that the
> variable id is an ARRAY. getElementById() takes a STRING as its  
> argument.

Strings can be treated as character arrays:

   http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:String#Character_access

However, this isn't a part of JavaScript supported by Internet  
Explorer (I think it is new in JS 1.5).

> At 4/11/2008 01:56 PM, tedd wrote:
>> document.getElementById(id).checked = true;
>
>
> Yeah, checked isn't a native DOM element property.

No, it is: http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html.html#attribute-checked

>  Use setAttribute.

Avoid setAttribute, it is broken in Internet Explorer (worse then IE8  
Best Standards Mode): http://www.quirksmode.org/dom/w3c_core.html#t910

-- 
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/





More information about the Javascript mailing list