Forum: Ruby on Rails Multiple selection in select box in Rhtml

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.
6471836a948fe7db6fc75b0b054a5838?d=identicon&s=25 Muruga Raj (murraj)
on 2007-03-17 07:14
How to select multiple entries in a select box in rhtml ?
In html , it can be done by setting 'multiple=true'. But in rhtml
'select-tag', how to do this ? Pls suggest me !
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (Guest)
on 2007-03-17 08:20
(Received via mailing list)
Hi, you can simply write it in standard HTML.

Good luck,

-Conrad
5db7f944f0e7448f5289ade733b0bd8a?d=identicon&s=25 unknown (Guest)
on 2007-03-17 09:53
(Received via mailing list)
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 Yuen <sayoyo@yahoo.com> wrote:
> html_options = {"size" => 5, "multiple" => true})
>
>
--
Cody Fauser
http://www.codyfauser.com


Muruga Raj escreveu:
6471836a948fe7db6fc75b0b054a5838?d=identicon&s=25 Muruga Raj (murraj)
on 2007-03-17 10:59
Very Good Answer ! Any way Thanks!!

Conrad Taylor wrote:
> Hi, you can simply write it in standard HTML.
>
> Good luck,
>
> -Conrad
389d846f26d5ef77d146962568ec80fa?d=identicon&s=25 lac (Guest)
on 2007-03-20 00:03
(Received via mailing list)
That works great! Thanks!!  But what if I need to display the form
with more then one value already selected?
I tried

  select_tag('letters[]',
options_for_select(['A','B','C','D'],'A','B'), :size =>5, :multiple =>
true)

but that raised the following error:  "Wrong number of arguments (3
for 2)".

Any suggestions?
This topic is locked and can not be replied to.