Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2008
    Posts
    102
    Thanks
    6
    Thanked 9 Times in 9 Posts

    checkbox.checked problem in IE6... confused

    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...
    Last edited by hotwheelharry; 03-22-2009 at 06:49 PM.

  • #2
    Regular Coder
    Join Date
    Jun 2008
    Posts
    102
    Thanks
    6
    Thanked 9 Times in 9 Posts
    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.

    Ok...
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •