Selected value


#1

I would like to pass the value selected in a select statement back so
that I can use it in the controller, through using a remote_function
call, and I cannot figure out what I am doing wrong:

view rhtml:
<select id=“widgets_id” name=“widgets[id]” onchange="<%=
remote_function( :update => “parts”, :url=> { :action => :loadParts } )
%>">
<%= options_from_collection_for_select @widgets, ‘id’, ‘name’ %>

Select is built fine. I cannot find documented anywhere, where I can
pass back the current value of the select (ie, something like "id =>
…)

Any help greatly appreciated. TIA


#2

Gerard <gerardgnm@…> writes:

I would like to pass the value selected in a select statement back so
that I can use it in the controller, through using a remote_function
call, and I cannot figure out what I am doing wrong:
[…]

Have a look at the remote_function() :with option.

Cheers,
Marco


#3

On 4/22/06, Gerard removed_email_address@domain.invalid wrote:

Select is built fine. I cannot find documented anywhere, where I can
pass back the current value of the select (ie, something like "id =>
…)

This should do what you want. (I split up the remote_function thing to
make it easier to read in the email.)

<% func = remote_function(:update => “parts”, :url => {:action =>
:loadParts}, :with => “‘id=’ + escape(value)” -%>

<%= options_from_collection_for_select @widgets, 'id', 'name' %>