#440 bug
Shanrong Zhao

Form.Element.Serializers selectMany

Reported by Shanrong Zhao | November 11th, 2008 @ 11:35 PM | in 1.7

Actually, I don't think it's a bug, but feel it would work better (if minor changes).

selectMany: function(element) {

var values, length = element.length;
if (!length) return null;

for (var i = 0, values = []; i < length; i++) {
  var opt = element.options[i];
  if (opt.selected) values.push(this.optionValue(opt));
return values;


If none of options is seleted, empty array "[]" will be returned. As a result, when you serialize the form, an annoying/extra"&" will appear in the query string. Compare to "SelectOne" function, "null" will be returned.

Minor changes suggested:

return values; => return (values.length)? values: null;

Best regards,


Comments and changes to this ticket

  • Tobie Langel

    Tobie Langel November 22nd, 2008 @ 05:18 PM

    • Assigned user set to “Tobie Langel”
    • State changed from “new” to “bug”
    • Milestone set to 1.7
    • Tag set to needs_patch, needs_tests

    As per w3c specs

    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.

    This is a bug and needs to be corrected.

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:26 AM

    • Tag changed from needs_patch, needs_tests to missing:tests, needs_patch

    [not-tagged:"needs_tests" tagged:"missing:tests" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:28 AM

    • Tag changed from missing:tests, needs_patch to missing:patch, missing:tests

    [not-tagged:"needs_patch" tagged:"missing:patch" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:36 AM

    • Tag changed from missing:patch, missing:tests to missing:patch, needs:tests

    [not-tagged:"missing:tests" tagged:"needs:tests" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:37 AM

    • Tag changed from missing:patch, needs:tests to needs:patch, needs:tests

    [not-tagged:"missing:patch" tagged:"needs:patch" bulk edit command]

  • T.J. Crowder

    T.J. Crowder November 16th, 2009 @ 04:50 PM

    • Assigned user cleared.

    [responsible:none bulk edit command]

  • Tisho Georgiev

    Tisho Georgiev March 1st, 2010 @ 09:41 PM

    • Tag changed from needs:patch, needs:tests to needs:patch, needs:tests, section:dom

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins