Skip to main content

Bug Tracker

Side navigation

#10108 closed bug (worksforme)

Opened August 22, 2011 02:28PM UTC

Closed August 22, 2011 03:48PM UTC

$(form).serialize() requires "selected" attribute in IE

Reported by: anonymous Owned by: anonymous
Priority: low Milestone: None
Component: attributes Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

In Firefox, a form that is serialized using the $(form).serialize() method will include HTML select element values whether or not the selected property is set on a select option. In IE, however, if the selected property is not set on any of the options, it is excluded from the serialize() result.

Attachments (0)
Change History (2)

Changed August 22, 2011 02:30PM UTC by rwaldron comment:1

component: unfiledattributes
owner: → anonymous
priority: undecidedlow
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/

Open the link and click to "Fork" (in the top menu) to get started.

Changed August 22, 2011 03:48PM UTC by dmethvin comment:2

resolution: → worksforme
status: pendingclosed

My test case is not seeing any problem in Firefox 6 or IE7/8 and the latest version of jQuery:

http://jsfiddle.net/dmethvin/zXmcP/

However, I do want to point out that select without an option selected is not good practice. The W3C spec says:

For menus, the control name is provided by a SELECT element and values are provided by OPTION elements. Only selected options may be successful. When no options are selected, the control is not successful and neither the name nor any values are submitted to the server when the form is submitted.
If no OPTION element has the selected attribute set, user agent behavior for choosing which option is initially selected is undefined. ... Since user agent behavior differs, authors should ensure that each menu includes a default pre-selected OPTION.