Bug Tracker

Opened 12 years ago

Closed 12 years ago

#10108 closed bug (worksforme)

$(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:


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.

Change History (2)

comment:1 Changed 12 years ago by Rick Waldron

Component: unfiledattributes
Owner: set to 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.

comment:2 Changed 12 years ago by dmethvin

Resolution: worksforme
Status: pendingclosed

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


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.

Note: See TracTickets for help on using tickets.