Closed
Bug 45867
Opened 25 years ago
Closed 23 years ago
setting a radio from js doesn't uncheck the previous checked radio
Categories
(Core :: XBL, defect, P3)
Tracking
()
RESOLVED
INVALID
mozilla1.0
People
(Reporter: pete, Assigned: bugzilla)
Details
Hey Ben, maybe i'm doing something wrong here . . .
If is set a radio like so:
document.getElementById('aRadio').checked=true;
the previously checked radio remains checked and i have two checked
radios . . .
So i ended up doing this for it to work:
var child=document.getElementById('radioGroupId').childNodes;
for(n=0;n<child.length;n++)
child[n].removeAttribute('checked');
document.getElementById('targetRadio').checked=true;
Thanks
pete
Comment 1•25 years ago
|
||
By the way, you can use the .selectedItem setter of <radiogroup> to get
the result you want (i.e., it will remove checked status from the
current selectedItem, and set it on the new selectedItem (automagic mutual
exclusion)):
var radiogroup = document.getElementById("aGroup");
radiogroup.selectedItem = document.getElementById("aRadio");
(But this bug is really about a possible change to the binding that might make
individual <radio> elements "aware" of their containment in the <radiogroup>).
Reporter | ||
Comment 2•25 years ago
|
||
Exactly John, thanks.
I am just use to html behavior.
You set a child to checked and their siblings are aware of the change.
pete
Comment 3•25 years ago
|
||
I'm not setting the selectedItem internally. this is wrong.
accepting.
Status: NEW → ASSIGNED
Target Milestone: --- → M20
Updated•23 years ago
|
Target Milestone: --- → mozilla1.0
Assignee | ||
Comment 5•23 years ago
|
||
You can't set .checked (which is now .selected) anymore. The only proper way to
do it is to set the radiogroup's selectedItem. Marking invalid.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•