Connecting Tech Pros Worldwide Help | Site Map
Reply
 
LinkBack Thread Tools Search this Thread
  #1  
Old August 18th, 2007, 02:00 PM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,228
Default Browser Quirk: Dynamically appended checked checkbox does not appear checked (IE)

Problem
Dynamically appended checkbox element does not appear checked despite setting the checked property state to true or "checked".

Browser
Internet Explorer

Example
The Javascript code:
Expand|Select|Wrap|Line Numbers
  1. var cb = document.createElement("input");
  2. cb.type = "checkbox";
  3. cb.name = "checkbox1";
  4. cb.id = "cbID";
  5. cb.checked = true;
  6. obj.appendChild(cb);
Solution
Use defaultChecked instead of checked:
Expand|Select|Wrap|Line Numbers
  1. cb.defaultChecked = true;
Alternative Solution
Set the checked state after appending the checkbox:
Expand|Select|Wrap|Line Numbers
  1. obj.appendChild(cb);
  2. cb.checked = true;
More Bugs, Quirks and Inconsistencies
Reply



Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.