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


#1

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


#2

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

select_tag(“form__list1[]”,

Estelle.


#3

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


#4

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


#5

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


#6

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


#7

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


#8

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


#9

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