[FIX][RBTN]Radio button onclick fires before clearing previous checked value

RESOLVED FIXED

Status

()

Core
DOM: Core & HTML
P3
normal
RESOLVED FIXED
17 years ago
9 years ago

People

(Reporter: Tim Powell, Assigned: rods (gone))

Tracking

Trunk
x86
Windows NT
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: Fix in hand)

Attachments

(1 attachment)

(Reporter)

Description

17 years ago
User-agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; m18) Gecko/20001010
BuildID: 2000101014

The onclick event handler for the radio button is called before the previous
value of the radio button is cleared. This is different than with Netscape 4.x
and IE. In these other browsers the current Radio array element is marked
checked, the old element is cleared, and then the onclick event fires.

The following code demonstrates having two radio buttons marked checked at the
same time:

<html>
<head>
<title>Radiobutton onClick and checked attribute test</title>
<script type="text/javascript">
function clickRadio()
{
	var t = document.forms[0].cb; //or document.getElementsByName("cb");
	var str = "";
	for (var i=0; i<t.length; i++)
		str += t[i].value + ":" + t[i].checked + " ";
	alert(str);
}
</script>
</head>
<body>
<form>
<input name=cb id=cb0 type=radio value="0" onclick="clickRadio()" checked><label
for="cb0">Zero</label><br>
<input name=cb id=cb1 type=radio value="1" onclick="clickRadio()"><label
for="cb1">One</label><br>
<input name=cb id=cb2 type=radio value="2" onclick="clickRadio()"><label
for="cb2">Two</label>
</form>
</body>
</html>

Click on item One and the alert shows "0:true 1:true 2:false". Having two
elements marked checked makes it hard to tell which is the current item in the
radio set.
Expected Result is for the alert to show "0:false 1:true 2:false". I'd expect
this breaks a lot of existing pages.

This may be a problem with the previous fix in bug 42972.

It also appears that the radio buttons are acting like checkboxes. You can click
on a radio button that is set and it will clear itself, the alert will show
"0:false 1:false 2:false" and then it will reset to be marked.
Rods, could you look into this problem?
Assignee: jst → rods
(Assignee)

Comment 2

17 years ago
Yes, it is wrong and I now what needs to be donw. This will have to be fixed in 
the next release.
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Target Milestone: --- → Future
(Assignee)

Updated

17 years ago
Summary: Radio button onclick fires before clearing previous checked value → [RBTN]Radio button onclick fires before clearing previous checked value
(Reporter)

Comment 3

17 years ago
Created attachment 19618 [details]
Testcase for radiobutton onclick (based on code above)
(Assignee)

Updated

17 years ago
Summary: [RBTN]Radio button onclick fires before clearing previous checked value → [FIX][RBTN]Radio button onclick fires before clearing previous checked value
Whiteboard: Fix in hand
(Assignee)

Updated

17 years ago
Target Milestone: Future → ---
(Assignee)

Comment 4

17 years ago
fixed
Status: ASSIGNED → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → FIXED
(Reporter)

Comment 5

17 years ago
*** Bug 62846 has been marked as a duplicate of this bug. ***
(Reporter)

Comment 6

17 years ago
*** Bug 62846 has been marked as a duplicate of this bug. ***

Comment 7

17 years ago
*** Bug 62846 has been marked as a duplicate of this bug. ***
Component: DOM Level 2 → DOM HTML

Comment 8

17 years ago
*** Bug 73723 has been marked as a duplicate of this bug. ***

Updated

9 years ago
Component: DOM: HTML → DOM: Core & HTML
QA Contact: vidur → general
You need to log in before you can comment on or make changes to this bug.