Skip to main content

Bug Tracker

Side navigation

#4878 closed bug (fixed)

Opened July 10, 2009 10:56AM UTC

Closed February 11, 2011 08:32PM UTC

val() tries to set multiple values on single select lists

Reported by: bennettmcelwee Owned by:
Priority: low Milestone: 1.4
Component: core Version: 1.3.2
Keywords: select val Cc:
Blocked by: Blocking:
Description

jQuery.fn.val(value) will select every matching option in a select list, even if it's not a multiple select list. It's invalid HTML for more than one option to be selected. When it happens, the browser has to pick one to display. Firefox and Safari pick the first selected option; IE6 picks the last.

Correct behaviour should probably be to select just the first matching value in these cases.

I'm attaching a patch to attributes.js rev 6333 that fixes the problem, along with a simple test page that shows the problem on IE6.

Attachments (3)
  • attributes.diff (0.8 KB) - added by bennettmcelwee July 15, 2009 12:36AM UTC.

    Proper patch file for rev 6333.

  • attributes.js-r6333-patch.txt (0.4 KB) - added by bennettmcelwee July 10, 2009 10:57AM UTC.

    Patch for attributes.js rev 6333

  • val-singleselect-test.html (1.0 KB) - added by bennettmcelwee July 10, 2009 10:58AM UTC.

    Test file showing the problem

Change History (3)

Changed November 18, 2010 02:52AM UTC by dmethvin comment:1

keywords: select valneedsreview select val
status: newopen

Should we try to force an error case into correct behavior?

Changed February 11, 2011 03:06AM UTC by bennettmcelwee comment:2

This is not a problem any more, due to related changes in jQuery 1.4.

Changed February 11, 2011 08:32PM UTC by jitter comment:3

keywords: needsreview select valselect val
milestone: → 1.4
priority: minorlow
resolution: → fixed
status: openclosed

Closing as reporter confirmed this has been fixed with 1.4 already.

test case