Ticket #6026 (closed bug: worksforme)
.change() handler fired when clicking select box in IE
| Reported by: | Stormrider | Owned by: | brandon |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4.2 |
| Component: | event | Version: | 1.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
When creating a dropdown box / menu and using the .change() event to bind a function to submit the form, in IE it triggers the function when clicking the select box.
When the page first loads, it works fine for the first time, then it fails for subsequent attempts - possibly because a selected="selected" has been added to one of the options by then (using server-side scripting). Tested in IE 7 & 8.
<script> $(function() {
$('#industry-form input[type=submit]').remove(); $('#industry-form select').change(function() {$('#industry-form').submit()});
}); </script>
<p>Please select the sector you are interested in from the drop-down box below:</p>
<form id="industry-form" action="index.php" method="get">
<select name="sector">
<option value="0">[Select Industry]</option> <option value="1">Aerospace</option> <option value="2">Automotive & Engineering</option> <option value="3">Chemicals & Plastics</option> <option value="4">Defence</option> <option value="5">Food & Drink</option> <option value="6">General Manufacturing</option> <option selected="selected" value="7">Healthcare</option> <option value="8">Paper & Packaging</option> <option value="9">Pharmaceuticals & Medical Products</option>
</select>
<input type="hidden" name="ar" value="144" />
<input type="submit" name="submit" value="Go >" />
</form>
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

This was fixed in jQuery 1.4.1.