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:
[CODE=javascript]var cb = document.create Element("input" );
cb.type = "checkbox";
cb.name = "checkbox1" ;
cb.id = "cbID";
cb.checked = true;
obj.appendChild (cb);[/CODE]
Solution
Use defaultChecked instead of checked:
[CODE=javascript]cb.defaultCheck ed = true;[/CODE]
Alternative Solution
Set the checked state after appending the checkbox:
[CODE=javascript]obj.appendChild (cb);
cb.checked = true;[/CODE]
More Bugs, Quirks and Inconsistencies
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:
[CODE=javascript]var cb = document.create Element("input" );
cb.type = "checkbox";
cb.name = "checkbox1" ;
cb.id = "cbID";
cb.checked = true;
obj.appendChild (cb);[/CODE]
Solution
Use defaultChecked instead of checked:
[CODE=javascript]cb.defaultCheck ed = true;[/CODE]
Alternative Solution
Set the checked state after appending the checkbox:
[CODE=javascript]obj.appendChild (cb);
cb.checked = true;[/CODE]
More Bugs, Quirks and Inconsistencies