Drop-down with multiple values selected

Hi everyone,

For my application I'm trying to create a drop-down with multiple
select that has multiple values already selected. I have the values
that I need to select in an array, but I don't know how to tell my
'select' statement how to highlight them.

Here is an example of what I mean:

select('search',
          'user_id',
          User.find_all.collect {|p| [ p.username, p.id ] },
          { },
          { :multiple => true, :size => 5, :name => 'search[user_id][]'
}) %>

Now I just need to make this drop-down select all of the items that are
in an array: 'options_to_select = [1,2,3]' for example.

Thank you for your time,

Jd

Jackdan wrote:

Hi everyone,

For my application I'm trying to create a drop-down with multiple
select that has multiple values already selected. I have the values
that I need to select in an array, but I don't know how to tell my
'select' statement how to highlight them.

Here is an example of what I mean:

select('search',
          'user_id',
          User.find_all.collect {|p| [ p.username, p.id ] },
          { },
          { :multiple => true, :size => 5, :name => 'search[user_id][]'
}) %>

Now I just need to make this drop-down select all of the items that are
in an array: 'options_to_select = [1,2,3]' for example.

Thank you for your time,

Jd

Drop down selects cannot select more than one item. if you need to do
that, you need a multi-select control. Just specify :multiple=>true in
a select_tag.

_Kevin