Forum: Ruby on Rails How to get all selected rows in the mutli-selection listbox?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
sayoyo S. (Guest)
on 2006-02-02 23:03
(Received via mailing list)
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
http://mail.yahoo.com
Estelle W. (Guest)
on 2006-02-03 07:15
(Received via mailing list)
I'm not sure, but try adding square brackets like this:

select_tag("form__list1[]",
...

Estelle.
sayoyo S. (Guest)
on 2006-02-03 16:11
(Received via mailing list)
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
http://mail.yahoo.com
Adam D. (Guest)
on 2006-02-03 16:27
(Received via mailing list)
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
Cody F. (Guest)
on 2006-02-03 16:45
(Received via mailing list)
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> wrote:
> html_options = {"size" => 5, "multiple" => true})
>
>
--
Cody F.
http://www.codyfauser.com
sayoyo S. (Guest)
on 2006-02-03 17:00
(Received via mailing list)
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> 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
> >
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
sayoyo S. (Guest)
on 2006-02-03 17:03
(Received via mailing list)
It works:)!!!!! Thanks you and Thank you very much
!!!!



--- Cody F. <removed_email_address@domain.invalid> wrote:

>
> > following function:
> > action: index
> protection around
> Cody F.
> http://www.codyfauser.com
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> 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.

http://www.geocities.com/sayoyo/

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
sayoyo S. (Guest)
on 2006-02-03 17:03
(Received via mailing list)
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> 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
> >
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> 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.

http://www.geocities.com/sayoyo/

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
sayoyo S. (Guest)
on 2006-02-03 17:03
(Received via mailing list)
Hi, Estelle

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

Saiho


--- Estelle W.
<removed_email_address@domain.invalid> wrote:

> > Hi,
> > select_tag("form__list1",
> > form__list1: "A"
> > http://mail.yahoo.com
>
__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
This topic is locked and can not be replied to.