how update a select onchange?

Hey all,
I have a select("post", "person_id", Person.find_all.collect {|p|
[ p.name, p.id ] }) and I would like to submit the value when it is
selected.
I know I have to do something like this: onchange="<%=
remote_function(:update => "options",
      :url => { :action => :update_options })
but how can I pass it the value of the selected option?

thanx in advance

Pat

remote_function(:update => "options",
     :url => { :action => :update_options },
     :with => "'post%5Bperson_id%5D='+$F('post_person_id')")

HTH,
Pratik

remote_function(:update => "options",
     :url => { :action => :update_options },
     :with => "'post%5Bperson_id%5D='+$F('post_person_id')")

Hey Pratik, thanx for your anwser,
basically, this is what I have:

<select id="config_<%= conf.conf_name %>" name="config[<%=
conf.conf_name %>]" onchange="<%=
remote_function( :url => { :action => :update ,
:id=>conf.id,'config[confvalue]'=>'+this[this.selectedIndex].value' })
%>"><option value="0" selected>No</option><option value="1"

Yes</option><option value="0" selected>No</option><option value="3"
Maybe</option></select>

the poblem is that the updated value of confvalue is
'this[this.selectedIndex].value' instead of the selected value.
I also tried something like that:

:with=>config[confvalue]'=>'+this[this.selectedIndex].value'

but in that case nothing get updated at all.
any idea what's wrong?

thanx in advance

Pat

Pat,

You can also use observe_field().

<%= select :post, :person_id, Person.find(:all).collect {|p| [ p.name,
p.id ] } %>
<%= observe_field :post_person_id, :url => { ... }, :with => 'post_person_id' %>

Hope this helps,

Patrick,

Here is a select that will be submitted via AJAX request when changed:

<%= select( :vehicle, :body_type,
            @body_types.collect {|bt| [bt, bt]},
            {},
            :onchange => remote_function( :with =>
"'vehicle[body_type]='+escape(value)",
                                          :loading =>
"Element.show('loading-indicator4')",
                                          :complete =>
evaluate_remote_response,
                                          :url => { :action =>
:vehicle_body_type_select } ) ) %>

This will run the method 'vehicle_body_type_select' in the current
controller, and when that action is executed the currently selected
value will be in 'params[:vehicle][:body_type]' from the :with
parameter. The method passes back Javascript via RJS statements which
are evaluated by the :complete item.

David

Patrick Aljord wrote: