If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

select onchange event not fired if selectedIndex changes from -1 to 0

RESOLVED DUPLICATE of bug 317078

Status

()

Firefox
General
--
major
RESOLVED DUPLICATE of bug 317078
12 years ago
12 years ago

People

(Reporter: Dave, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

If a select's selectedIndex is set to -1, and the the user selects the first option (selectedIndex=0), the onchange event is not fired.

This worked in FF 1.0. 

Reproducible: Always

Steps to Reproduce:
Run example html example pasted in additional information



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Select Test</title>

<script language='JavaScript'>

function onlyOneSelection(sel1, sel2){
	alert(sel1.id + " selected index = " + sel1.selectedIndex);
	if(sel1.selectedIndex >= 0){
		sel2.selectedIndex = -1;
	}
}

</script>


</head>

<body onload="onLoad()">
<form name="data"  method='post' onSubmit=""  action=''>
<table>

   	<tr>

	<td> Select 1<br/>
	  <select id='select1' name='member' size='1' onchange="onlyOneSelection(this, document.data.select2)">
	    <option value="1">Option 1</option> <option value="2">Option 2</option>
	  </select>
	</td>

 	<td> Select 2 <br/>
 	  <select id='select2' name='member' size='1' onchange="onlyOneSelection(this, document.data.select1)">
	  	<option value="3">Option 1 </option> <option value="4">Option 2</option>
	  </select>
	</td>

	</tr>

</table>
</form>

<script language='JavaScript'>
	document.data.select1.selectedIndex = -1;
	document.data.select2.selectedIndex = -1;
</script>

</body>
</html>

Comment 1

12 years ago
Created attachment 222044 [details]
reporter's testcase as text/html

I think I can reproduce the bug using a Mac trunk nightly from last week.

Comment 2

12 years ago

*** This bug has been marked as a duplicate of 317078 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.