arei.net
IE Bug: Input type="checkbox" checked property

So I found a fun little bug in IE 6 just now.  Don’t know if it is in IE 7 or 8.

Essentially if you have an element as shown:

<input type="checkbox" id="test-checkbox" />

And do the call:

document.getElementById("test-checkbox").checked

The result will not always reflect the checked state of the element.  The reason for this is the lack of a “name” attribute in the input element.  IE 6 appears to reset the state of any checkbox form element that is missing a name attribute under certain conditions.  Adding the “name”  attribute solves this problem.

Spent 2 hours on that gem.

permalink: http://www.arei.net/archives/40