View Full Version : checkbox.checked problem in IE6... confused

03-22-2009, 06:39 PM
I have a little function that is called with an inline script tag that creates some checkboxes for a form. Inline script isn't very kosher, but im doing it for a particular timing issue.

Based on cookie values, the checkboxes are automatically filled in.

My function is called inline, creates some checkboxes with document.createElement, then reads the cookie values and sets the checked property to true or false, then appends the element to a form, then the form to a div, then the div to the body.

It all works fine in FF & Chrome, but in IE6 the check boxes show up fine, they just aren't checked when they should be.

I even set up a little alert after I set the property to true (if it should be) and IE says true when i set it (which is right). But when it displays the check box it is still not checked.

What is up?!
I have lots of code, so i don't really want to include it (and im sure you wouldn't want to read it ;) ).

Could anyone help with advice on what i'm doing wrong, or an IE quirk.
Thanks a bunch.

Brand new info: (EDIT)
I added the id property to the checkboxes created dynamically in the script. AFTER the page loaded I did a little $("checkboxID").checked = true; in the URL bar and the check box checked itself.

It means that the id property I assign in the script worked but even a direct assignment of "true" to the checked property won't work on the same variable... UGH.

This just confuses me more... :(

03-22-2009, 07:36 PM
Well howdy doodie... I solved my problem.

Let me just say first that IE is incredibly annoying and stupid and ahhhhhhhhhhhhhhhhhhhhh. I hate it so much.

When creating checkboxes in memory, IE resets whatever checked status you set when it inserts it into the document. That's why when i set it to true it just ignored it.

To solve, just set the defaultChecked property instead of checked.
This is probably pretty common knowledge to "pros" but here it is anyways to help some noobs like me from making the same mistake.

Anyways, final thoughts: IE stinks.