On 4/22/06, Gerard <gerardgnm@gmail.com> wrote:> 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>
>
> 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)"
-%>
<select id="widgets_id" name="widgets[id]"
onchange="<%=func%>">
<%= options_from_collection_for_select @widgets, ''id'',
''name'' %>
</select>