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

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Muruga R. (Guest)
on 2007-03-17 08: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 !
Conrad T. (Guest)
on 2007-03-17 09:20
(Received via mailing list)
Hi, you can simply write it in standard HTML.

Good luck,

unknown (Guest)
on 2007-03-17 10: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

On 2/3/06, Saiho Y. <removed_email_address@domain.invalid> wrote:
> html_options = {"size" => 5, "multiple" => true})
Cody F.

Muruga R. escreveu:
Muruga R. (Guest)
on 2007-03-17 11:59
Very Good Answer ! Any way Thanks!!

Conrad T. wrote:
> Hi, you can simply write it in standard HTML.
> Good luck,
> -Conrad
lac (Guest)
on 2007-03-20 01: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

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

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.