# Selected value

**URL:** <https://www.ruby-forum.com/t/selected-value/94149>\
**Category:** Rails\
**Created:** [April 23, 2006, 1:01am UTC](https://www.ruby-forum.com/t/selected-value/94149 "2006-04-23T01:01:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 23, 2006, 1:01am UTC](https://www.ruby-forum.com/t/selected-value/94149/1 "2006-04-23T01:01:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 27, 2006, 4:25am UTC](https://www.ruby-forum.com/t/selected-value/94149/2 "2006-05-27T04:25:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 27, 2006, 4:43am UTC](https://www.ruby-forum.com/t/selected-value/94149/3 "2006-05-27T04:43:51Z")

</div>

On 4/22/06, Gerard [removed\_email\_address@domain.invalid](mailto: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' %\>
