Closed Bug 588927 Opened 14 years ago Closed 2 years ago

Wrong input button onClick event fired when a submit button is clicked from within a fieldset and label tags.

Categories

(Core :: DOM: Events, defect)

defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: mbuonaccorsi, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8

The wrong onClick event will be fired in a specific scenario when multiple input buttons are located within a fieldset tag and then within a label tag as in the following example:

<html>
	<body>
		<form action="#">
			<fieldset>
				<label>
					<input type="button" value="Simple Button" onClick="javascript:alert('Simple button pressed.');" />
					<input type="submit" value="Submit Button" />
				</label>
			</fieldset>
		</form>
	</body>
</html>

The normal input button has the onClick event handler.  When the submit button is clicked, the onClick event handler for the first (normal) button is fired instead.

Remove the label tag wrapping the two buttons and it works correctly.

Reproducible: Always

Steps to Reproduce:
1. Save example code into an HTML from the description.
2. Open example code file in firefox 3.6
3. Click the submit button and the alert box appears showing that the wrong event handler was fired.


Expected Results:  
The submit button should only submit the form and not fire the onClick event handlers of other buttons.
Attached file testcase from the reporter (deleted) —
I can reproduce on Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.0b6pre) Gecko/20100903 Firefox/4.0b6pre with the attached testcase.
Status: UNCONFIRMED → NEW
Component: General → Layout: Form Controls
Ever confirmed: true
OS: Windows 7 → All
Product: Firefox → Core
QA Contact: general → layout.form-controls
Hardware: x86_64 → All
Version: unspecified → Trunk
Severity: normal → S3

I could not reproduce with the attached testcase any more.

Status: NEW → RESOLVED
Closed: 2 years ago
Component: Layout: Form Controls → DOM: Events
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: