# onChange =\> remote\_function - Not able to get current id

**URL:** <https://www.ruby-forum.com/t/onchange-remote-function-not-able-to-get-current-id/168729>\
**Category:** Rails\
**Created:** [May 25, 2009, 7:16am UTC](https://www.ruby-forum.com/t/onchange-remote-function-not-able-to-get-current-id/168729 "2009-05-25T07:16:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![devirv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@devirv](https://www.ruby-forum.com/u/devirv)\
**Post date:** [May 25, 2009, 7:16am UTC](https://www.ruby-forum.com/t/onchange-remote-function-not-able-to-get-current-id/168729/1 "2009-05-25T07:16:13Z")

</div>

Hi,

Below is the code I am using to display drop down. This drop down is for  
displaying categories.

\<% form\_for :category do |form| %\>  
\<%= form.collection\_select(:id,@categories, :id,  
:category\_name, {},  
{:onChange =\> remote\_function(:url=\>{:action=\>‘say\_hello’,  
:with =\> “‘id=’+value”},  
:update=\>‘mydiv’)}  
) %\>  
\<% end %\>

I want to get the ‘current category id’ during onchange. Using :with =\>  
“‘id=’+value” I am not able to get it.

Plaese anyone suggest

---

<div class="post-metadata">

**Author:** ![devirv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@devirv](https://www.ruby-forum.com/u/devirv)\
**Post date:** [May 25, 2009, 8:08am UTC](https://www.ruby-forum.com/t/onchange-remote-function-not-able-to-get-current-id/168729/2 "2009-05-25T08:08:56Z")

</div>

Maybe “with” section should look like with =\> ‘id=’+value? I think in  
your variant you assign to id a string value ‘value’.

Regards,  
Bob

---

<div class="post-metadata">

**Author:** ![devirv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@devirv](https://www.ruby-forum.com/u/devirv)\
**Post date:** [May 25, 2009, 8:35am UTC](https://www.ruby-forum.com/t/onchange-remote-function-not-able-to-get-current-id/168729/3 "2009-05-25T08:35:15Z")

</div>

On 25/05/2009, at 3:16 PM, Devi Rv wrote:

> {:onChange =\> remote\_function(:url=\>{:action=\>‘say\_hello’,  
> :with =\> “‘id=’+value”},  
> :update=\>‘mydiv’)}  
> ) %\>  
> \<% end %\>
> 
> I want to get the ‘current category id’ during onchange. Using :with  
> =\>  
> “‘id=’+value” I am not able to get it.

For a start, you have :with as part of the :url hash… it should be  
on the same level as :update.

Julian.

* * *

Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
Twitter: [http://twitter.com/random8r](http://twitter.com/random8r)  
Learn: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)  
Latest: How to use Unix basics at [http://sensei.zenunit.com/](http://sensei.zenunit.com/)
