# Accessing the value chosen in a dropdown menu

**URL:** <https://www.ruby-forum.com/t/accessing-the-value-chosen-in-a-dropdown-menu/108086>\
**Category:** Ruby\
**Created:** [June 28, 2007, 11:25pm UTC](https://www.ruby-forum.com/t/accessing-the-value-chosen-in-a-dropdown-menu/108086 "2007-06-28T23:25:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [June 28, 2007, 11:25pm UTC](https://www.ruby-forum.com/t/accessing-the-value-chosen-in-a-dropdown-menu/108086/1 "2007-06-28T23:25:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [June 29, 2007, 12:03am UTC](https://www.ruby-forum.com/t/accessing-the-value-chosen-in-a-dropdown-menu/108086/2 "2007-06-29T00:03:58Z")

</div>

On 6/28/07, James [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

[http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000535](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000535)
