Forum: Ruby on Rails selected value

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B1d0b409ee9c49b67556748d268df420?d=identicon&s=25 Gerard (Guest)
on 2006-04-23 01:01
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 =>
...)

Any help greatly appreciated.  TIA
77fec2b94c481ad3d2b2135b1f07ef5f?d=identicon&s=25 Marco Lazzeri (Guest)
on 2006-05-27 04:25
(Received via mailing list)
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
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-05-27 04:43
(Received via mailing list)
On 4/22/06, Gerard <gerardgnm@gmail.com> 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)" -%>

<select id="widgets_id" name="widgets[id]" onchange="<%=func%>">
  <%= options_from_collection_for_select @widgets, 'id', 'name' %>
</select>
This topic is locked and can not be replied to.