# How to get all selected rows in the mutli-selection listbox?

**URL:** <https://www.ruby-forum.com/t/how-to-get-all-selected-rows-in-the-mutli-selection-listbox/100472>\
**Category:** Rails\
**Created:** [February 2, 2006, 10:03pm UTC](https://www.ruby-forum.com/t/how-to-get-all-selected-rows-in-the-mutli-selection-listbox/100472 "2006-02-02T22:03:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [February 2, 2006, 10:03pm UTC](https://www.ruby-forum.com/t/how-to-get-all-selected-rows-in-the-mutli-selection-listbox/100472/1 "2006-02-02T22:03:27Z")

</div>

Hi,

I have created a multiple selection listbox with  
rails, when I try to get the rows selected by user,  
rails send back only the first one, how can I get the  
other selected rows???

I created the listbox with the following function:

select\_tag(“form\_\_list1”,  
options\_for\_select([“A”,“B”,“C”,“D”], selected = “A”),  
html\_options = {“size” =\> 5, “multiple” =\> true})

What I get from params is :

!map:HashWithIndifferentAccess  
commit: Next  
action: index  
controller: cellfiles  
form\_\_list1: “A”

Thanks you very much

Saiho

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[Yahoo Mail - Organized Email](https://mail.yahoo.com)**
>
> It's time to get stuff done with Yahoo Mail. Just add your Gmail, Outlook, AOL or Yahoo Mail to get going. We automatically organize all the things life throws at you, like receipts and attachments, so you can find what you need fast. Plus, we've got...

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [February 3, 2006, 6:15am UTC](https://www.ruby-forum.com/t/how-to-get-all-selected-rows-in-the-mutli-selection-listbox/100472/2 "2006-02-03T06:15:08Z")

</div>

I’m not sure, but try adding square brackets like this:

select\_tag(“form\_\_list1[]”,  
…

Estelle.

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [February 3, 2006, 3:11pm UTC](https://www.ruby-forum.com/t/how-to-get-all-selected-rows-in-the-mutli-selection-listbox/100472/3 "2006-02-03T15:11:56Z")

</div>

Hi,  
I have created a multiple selection listbox with  
rails, when I try to get the rows selected by user,  
rails send back only the first one, how can I get the  
other selected rows??? I created the listbox with the  
following function:

select\_tag(“form\_\_list1”,  
options\_for\_select([“A”,“B”,“C”,“D”], selected = “A”),  
html\_options = {“size” =\> 5, “multiple” =\> true})

What I get from params is :

!map:HashWithIndifferentAccess  
commit: Next  
action: index  
controller: cellfiles  
form\_\_list1: “A”

Thanks you very much

Saiho

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [February 3, 2006, 3:27pm UTC](https://www.ruby-forum.com/t/how-to-get-all-selected-rows-in-the-mutli-selection-listbox/100472/4 "2006-02-03T15:27:09Z")

</div>

hmm you might need to do something like form\_list1[] instead of just  
form\_list1 to get all the values into an array.

try that

adam

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [February 3, 2006, 3:45pm UTC](https://www.ruby-forum.com/t/how-to-get-all-selected-rows-in-the-mutli-selection-listbox/100472/5 "2006-02-03T15:45:19Z")

</div>

Saiho,

Try this:

select\_tag(‘letters[]’, options\_for\_select([‘A’,‘B’,‘C’,‘D’], ‘A’),  
:size =\> 5, :multiple =\> true)

You need to add the [] to the name to get back an array of selected  
values.

On 2/3/06, Saiho Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> html\_options = {“size” =\> 5, “multiple” =\> true})

–  
Cody F.  
[http://www.codyfauser.com](http://www.codyfauser.com)

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [February 3, 2006, 4:03pm UTC](https://www.ruby-forum.com/t/how-to-get-all-selected-rows-in-the-mutli-selection-listbox/100472/6 "2006-02-03T16:03:27Z")

</div>

It works:)!!! Thanks you and Thank you very much  
!!!

— Cody F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > following function:  
> > action: index  
> > protection around  
> > Cody F.  
> > [http://www.codyfauser.com](http://www.codyfauser.com)
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

If God really exists, I would like to  
know what the dinosaurs have done to  
deserve their extinction.

Water is unknown to fishes,  
until they discover air.

> **[Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos](https://www.yahoo.com)**
>
> Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [February 3, 2006, 4:03pm UTC](https://www.ruby-forum.com/t/how-to-get-all-selected-rows-in-the-mutli-selection-listbox/100472/7 "2006-02-03T16:03:27Z")

</div>

Hi Adam,

Finally, I understand how to make it works:) Thanks  
you and Thank you very much !!!

Saiho

— Adam D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Hi,  
> > options\_for\_select([“A”,“B”,“C”,“D”], selected =
> > 
> > Rails mailing list  
> > removed\_email\_address@domain.invalid
> 
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> > 
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

If God really exists, I would like to  
know what the dinosaurs have done to  
deserve their extinction.

Water is unknown to fishes,  
until they discover air.

> **[Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos](https://www.yahoo.com)**
>
> Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [February 3, 2006, 4:00pm UTC](https://www.ruby-forum.com/t/how-to-get-all-selected-rows-in-the-mutli-selection-listbox/100472/8 "2006-02-03T16:00:24Z")

</div>

Hi,

I try this but, it doesn’t work

form\_\_list1 = []  
select\_tag(form\_\_list1,  
options\_for\_select([“A”,“B”,“C”,“D”], selected =“A”),  
html\_options = {“size” =\> 5, “multiple” =\> true})

I get only A even I chose A,B,C

!map:HashWithIndifferentAccess  
“”: “A”  
commit: Previous  
action: index  
controller: atlasmain

have any idea???

Thanks you very much!!!

Saiho

— Adam D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Hi,  
> > options\_for\_select([“A”,“B”,“C”,“D”], selected =
> > 
> > Rails mailing list  
> > removed\_email\_address@domain.invalid
> 
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> > 
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [February 3, 2006, 4:03pm UTC](https://www.ruby-forum.com/t/how-to-get-all-selected-rows-in-the-mutli-selection-listbox/100472/9 "2006-02-03T16:03:27Z")

</div>

Hi, Estelle

It works:)!!! Thanks you and Thank you very much  
!!!

Saiho

— Estelle W.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Hi,  
> > select\_tag(“form\_\_list1”,  
> > form\_\_list1: “A”  
> > [http://mail.yahoo.com](http://mail.yahoo.com)

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object
