Ticket #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: | ||
| Blocking: | Blocked by: |
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.
Change History
comment:1 Changed 21 months ago by rwaldron
- Owner set to anonymous
- Priority changed from undecided to low
- Status changed from new to pending
- Component changed from unfiled to attributes
comment:2 Changed 21 months ago by dmethvin
- Status changed from pending to closed
- Resolution set to worksforme
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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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.