# Select changed event for collection\_select

**URL:** <https://www.ruby-forum.com/t/select-changed-event-for-collection-select/106795>\
**Category:** Rails\
**Created:** [June 14, 2007, 7:48am UTC](https://www.ruby-forum.com/t/select-changed-event-for-collection-select/106795 "2007-06-14T07:48:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/858c86/32.png) [@bins](https://www.ruby-forum.com/u/bins)\
**Post date:** [June 14, 2007, 7:48am UTC](https://www.ruby-forum.com/t/select-changed-event-for-collection-select/106795/1 "2007-06-14T07:48:46Z")

</div>

Hello,

I’m using collection\_select in one of the Rails application as follows.

\<%= collection\_select(“occupation”,“id”,@occupations,“id”,“name”)%\>

Could you please tell how I can call a javascript function on selecting  
an item.

thanks in advance  
bins.

---

<div class="post-metadata">

**Author:** ![bins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/858c86/32.png) [@bins](https://www.ruby-forum.com/u/bins)\
**Post date:** [February 20, 2008, 6:49pm UTC](https://www.ruby-forum.com/t/select-changed-event-for-collection-select/106795/2 "2008-02-20T18:49:35Z")

</div>

Hi bins,

Could you point me to a solution for this problem ?  
I’ve stuck on it for about 2 days now. Cannot find any useful  
suggestions on the web.

cheers,  
Kupsztal

On Jun 14 2007, 5:48 am, bins [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![bins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/858c86/32.png) [@bins](https://www.ruby-forum.com/u/bins)\
**Post date:** [February 20, 2008, 6:58pm UTC](https://www.ruby-forum.com/t/select-changed-event-for-collection-select/106795/3 "2008-02-20T18:58:19Z")

</div>

use the onchange event of the enclosing select tag

if you use rails select in the html-options add something like:  
:onchange =\> ‘change\_procedure(this.value)’
