Closed
Bug 327020
Opened 18 years ago
Closed 18 years ago
.setAttribute("checked", true) don't work allways.. But .checked=true; works
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 223003
People
(Reporter: adrenalinup, Unassigned)
Details
Attachments
(1 file)
790 bytes,
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1 setAttribute('checked',true); in some situation don't work. I had multiple checkbox what must be all checked on "check all" button click(using setAttribute('checked',true)), but if user deselect one, and click again on "check all", the manual unchecked checkbox, didn't want anymore to be checked. If instead of .setAttribute('checked',true), i use .checked=true, all works as supposed. The IE&Opera also don't have this bug. Reproducible: Always Steps to Reproduce: 1. Click on check all 2. Unselect a checkbox 3. Click again on "check all" Actual Results: The manual unchecked checkbox, after "check all", remain unchecked Expected Results: The manual unchecked checkbox, after "check all", must be also checked.
Reporter | ||
Comment 1•18 years ago
|
||
Reporter | ||
Comment 2•18 years ago
|
||
Comment on attachment 211736 [details] Testcase ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> ><HTML><HEAD><TITLE>Title</TITLE></HEAD><BODY> >(click on "check all" button, after, uncheck a chk, and click again on "check all", it don't seem to check the manual unchecked checkbox..)<BR/> ><INPUT type="button" value="Check all" onclick="checkall();"/> ><DIV id="checkboxs"> ><INPUT type="checkbox"/>Chk1 ><INPUT type="checkbox"/>Chk2 ><INPUT type="checkbox"/>Chk3 ></DIV> ><SCRIPT type="text/javascript"> >function checkall() { > inputs = document.getElementById('checkboxs').getElementsByTagName('input'); > var i; > for (i=0;i<inputs.length;i++) { > inputs[i].setAttribute('checked',true); > //inputs[i].checked=true; //With this way to check, no bugs, all work as supposed.. > } >} ></SCRIPT> ></BODY></HTML>
Attachment #211736 -
Attachment is obsolete: true
Reporter | ||
Updated•18 years ago
|
Attachment #211736 -
Attachment is obsolete: false
Comment 3•18 years ago
|
||
Yes, that's the difference between the dom property .checked and the attribute checked. This is not a bug. *** This bug has been marked as a duplicate of 223003 ***
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → DUPLICATE
Reporter | ||
Comment 4•18 years ago
|
||
(In reply to comment #3) > Yes, that's the difference between the dom property .checked and the attribute > checked. > This is not a bug. > > *** This bug has been marked as a duplicate of 223003 *** > It's odd, and i think this will cause confusion to the web developers in future.. FF should act like other browsers..
Status: RESOLVED → UNCONFIRMED
Resolution: DUPLICATE → ---
Comment 5•18 years ago
|
||
> It's odd, and i think this will cause confusion to the web developers in > future.. "Changes to this [checked] attribute change the state of the form control, but do not change the value of the HTML checked attribute of the INPUT element." http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-30233917 If you replace in attachment 211736 [details] this line: inputs[i].setAttribute('checked',true); with these 4 lines: if(!inputs[i].checked) { inputs[i].click(); }; then you'll get the expected results in all browsers (Seamonkey 1.x, Firefox 1.x, IE 7 beta 2, Opera 9, etc.) Resolving as DUPLICATE of bug 223003 *** This bug has been marked as a duplicate of 223003 ***
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago → 18 years ago
Resolution: --- → DUPLICATE
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•