Can't get form results from a mutiple select box...

Hey everyone,
This seems really elementary and I have no clue what is wrong... I have
a form that has two multiple select boxes (using some javascript to
shift items from the left select box to the right box and vice versa)
and I want to grab what is in the second box after the user clicks
submit. It seems that each time I try to get that info in my controller,
it is returning nil. My form is as follows:

<%= form_tag :controller => 'push', :action => 'index', :type => 'test'
-%>
Choose users to sync (<%= @address_num %> total users)
<select name="sel1" style="width:200px" size="10" multiple="multiple">
  <% @address_array.each do |item| %>
  <option value="<%= item %>"><%= item %></option>
  <% end %>
</select>
<input type="button" value="--&gt;" onclick="moveOptions(this.form.sel1,
this.form.sel2);" />
<input type="button" value="&lt;--" onclick="moveOptions(this.form.sel2,
this.form.sel1);" />

<select name="sel2" style="width:200px" size="10" multiple="multiple">
  <option value="1">All Users (default)</option>
</select>

<%= submit_tag 'submit' %>
<%= end_form_tag -%>

In my controller, I have:

@results = params[:sel2]

but it turns out that @results is nil every time!

Does anybody know what is going wrong??

Thanks!!
- Jeff Miller

I just figured out something... If I actually select something in the
second box, it works... but if there are multiple ones, it doesn't. If
multiple items are selected, it only passes the first in the box... I
realize now that this is an HTML problem and I will have to just do a
bunch of googling, but if anyone knows how to overcome this, any help
would be appreciated.

Thanks,
- Jeff Miller

Hi, I'm just starting a project and want to implement the same
functionality. I would be very interested in knowing if/how you
resolved this issue. How are you handling loading both lists on page
load? That is, when you are editing an item, I would assume that you
would only load the "available" list with non-selected items and the
"selected" list with only those items previously selected.

TIA,
Henry

Jeff Miller wrote:

Hey everyone,
This seems really elementary and I have no clue what is wrong... I have
a form that has two multiple select boxes (using some javascript to
shift items from the left select box to the right box and vice versa)
and I want to grab what is in the second box after the user clicks
submit. It seems that each time I try to get that info in my controller,
it is returning nil. My form is as follows:

<%= form_tag :controller => 'push', :action => 'index', :type => 'test'
-%>
Choose users to sync (<%= @address_num %> total users)
<select name="sel1" style="width:200px" size="10" multiple="multiple">
  <% @address_array.each do |item| %>
  <option value="<%= item %>"><%= item %></option>
  <% end %>
</select>
<input type="button" value="--&gt;" onclick="moveOptions(this.form.sel1,
this.form.sel2);" />
<input type="button" value="&lt;--" onclick="moveOptions(this.form.sel2,
this.form.sel1);" />

<select name="sel2" style="width:200px" size="10" multiple="multiple">
  <option value="1">All Users (default)</option>
</select>

<%= submit_tag 'submit' %>
<%= end_form_tag -%>

pls try to name <select name="sel2[]"> like this (rest is same)
  <option value="1">All Users (default)</option>
</select>
In the controller pls try params[:sel2]||[]. I think this will give u
the all the values of all the selected options in the select drop down.