Closed Bug 57239 Opened 24 years ago Closed 24 years ago

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

Categories

(Core :: DOM: Core & HTML, defect, P3)

x86
Windows NT
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: tpowellmoz, Assigned: rods)

References

Details

(Whiteboard: Fix in hand)

Attachments

(1 file)

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
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
Summary: Radio button onclick fires before clearing previous checked value → [RBTN]Radio button onclick fires before clearing previous checked value
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
Target Milestone: Future → ---
fixed
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
*** Bug 62846 has been marked as a duplicate of this bug. ***
*** Bug 62846 has been marked as a duplicate of this bug. ***
*** Bug 62846 has been marked as a duplicate of this bug. ***
Component: DOM Level 2 → DOM HTML
*** Bug 73723 has been marked as a duplicate of this bug. ***
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.

Attachment

General

Creator:
Created:
Updated:
Size: