# Getting values from multiple select

**URL:** <https://discuss.rubyonrails.org/t/getting-values-from-multiple-select/42968>\
**Category:** rubyonrails-talk\
**Created:** [May 28, 2009, 2:20pm UTC](https://discuss.rubyonrails.org/t/getting-values-from-multiple-select/42968 "2009-05-28T14:20:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [May 28, 2009, 2:20pm UTC](https://discuss.rubyonrails.org/t/getting-values-from-multiple-select/42968/1 "2009-05-28T14:20:17Z")

</div>

I try to get the values from a multiple select without luck. This is my select:

\<%= select "product", "items", @options, {}, { :multiple =\> true } %\>

If I add it directly to a column in the db I get:

---

<div class="post-metadata">

**Author:** ![Freddy\_Andersen](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@Freddy\_Andersen](https://discuss.rubyonrails.org/u/Freddy_Andersen)\
**Post date:** [May 28, 2009, 2:37pm UTC](https://discuss.rubyonrails.org/t/getting-values-from-multiple-select/42968/2 "2009-05-28T14:37:20Z")

</div>

Is this in a form\_for? if not you should use select\_tag

[http://apidock.com/rails/ActionView/Helpers/FormTagHelper/select\_tag](http://apidock.com/rails/ActionView/Helpers/FormTagHelper/select_tag)

What do you have in @options?

This is the select method select(object, method, choices, options = {}, html\_options = {})

Examples here [select (ActionView::Helpers::FormOptionsHelper) - APIdock](http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/select)

To debug these issues you should have a look at the compiled source with view source in the browser and see what you got.

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [May 28, 2009, 6:46pm UTC](https://discuss.rubyonrails.org/t/getting-values-from-multiple-select/42968/3 "2009-05-28T18:46:41Z")

</div>

Freddy Andersen wrote:

> Is this in a form\_for? if not you should use select\_tag
> 
> [select\_tag (ActionView::Helpers::FormTagHelper) - APIdock](http://apidock.com/rails/ActionView/Helpers/FormTagHelper/select_tag)
> 
> What do you have in @options?
> 
> This is the select method select(object, method, choices, options = {}, html\_options = {})
> 
> Examples here [select (ActionView::Helpers::FormOptionsHelper) - APIdock](http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/select)
> 
> To debug these issues you should have a look at the compiled source with view source in the browser and see what you got.

That helped. But I only get the first value. Even if I use "items".

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [May 30, 2009, 10:10am UTC](https://discuss.rubyonrails.org/t/getting-values-from-multiple-select/42968/4 "2009-05-30T10:10:56Z")

</div>

Where is it going wrong ? Does your controller only ever say the first value or do your logs show that the controller receives multiple values. Look at the html source: does the name of the select tag end with ?

Fred
