Forum: Ruby accessing the value chosen in a dropdown menu

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
72a449d6bfff83e068da087266289bb4?d=identicon&s=25 James (Guest)
on 2007-06-28 23:25
I have an array of frame colors called @frame_color and I created a
dropdown menu that triggers a remote_function when the value is changed.
The problem is that I can't seem to figure out how to pass the value of
the selected string from the dropdown menu.

this is the code I have:

<%= select_tag(:frame_color, options_for_select(@frame_color), :onchange
=> remote_function(:update => "middle_sub_right", :url => {:action =>
'print_change', :color => params[:frame_color], :id => @prints, :photo
=> @photo}))%>

all I need is for this to happen; if someone picks brown from the
dropdown menu then brown will be passed to :color =>

thanks for any help.
813f535246722b7bf02aacc9ce818de8?d=identicon&s=25 Bob Showalter (Guest)
on 2007-06-29 00:03
(Received via mailing list)
On 6/28/07, James <> wrote:
> => @photo}))%>
(You should be asking on the Rails list. Rails != Ruby)

Anyway, that won't work, because params[:frame_color] is being
evaluated as the view is being rendered.

Use observe_field() for this; it handles passing the value to the
remote function for you.
This topic is locked and can not be replied to.