# Select Multiple - does it work? Help!

**URL:** <https://www.ruby-forum.com/t/select-multiple-does-it-work-help/123449>\
**Category:** Rails\
**Created:** [December 17, 2007, 9:39pm UTC](https://www.ruby-forum.com/t/select-multiple-does-it-work-help/123449 "2007-12-17T21:39:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 17, 2007, 9:39pm UTC](https://www.ruby-forum.com/t/select-multiple-does-it-work-help/123449/1 "2007-12-17T21:39:16Z")

</div>

I realize that doing a select with multiple must work, yet despite so  
many attempts following dozens of examples I have yet to get any  
success. I have the following (example) code:

\<%= select\_tag ‘test[]’, options\_for\_select([“one”, “two”, “three”],  
[“one”]), { :multiple =\> true, :size =\>5, :id =\> “test” } %\>

Note I have the brackets after test - so Rails knows its an array.  
When I select one and two in the form I get this:

“test”=\>[“two”]

in my log, instead of both entries. What am I doing wrong? This  
should be a simple task and I’ve been arguing with it all day.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 17, 2007, 10:36pm UTC](https://www.ruby-forum.com/t/select-multiple-does-it-work-help/123449/2 "2007-12-17T22:36:47Z")

</div>

Here is the syntax for multiple-select:

```
    <%= select_tag 'categories[]',
        options_for_select( @categories ), { :multiple => true,
                                             :size => 15,
                                             :style => 

```

“width:250px” }  
%\>

It looks like you don’t need the :id parameter. If you select multiple  
values, an array with multiple ids will be submitted to the server.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 17, 2007, 11:36pm UTC](https://www.ruby-forum.com/t/select-multiple-does-it-work-help/123449/3 "2007-12-17T23:36:00Z")

</div>

Unfortunately when I do what you’ve got verbatim - I get one parameter  
(whatever is the last selected one) sent, as an array.
