# Collection\_text onchange event

**URL:** <https://www.ruby-forum.com/t/collection-text-onchange-event/175984>\
**Category:** Rails\
**Created:** [September 23, 2009, 11:49am UTC](https://www.ruby-forum.com/t/collection-text-onchange-event/175984 "2009-09-23T11:49:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![subashinikumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/0ea827/32.png) [@subashinikumar](https://www.ruby-forum.com/u/subashinikumar)\
**Post date:** [September 23, 2009, 11:49am UTC](https://www.ruby-forum.com/t/collection-text-onchange-event/175984/1 "2009-09-23T11:49:35Z")

</div>

hi,

I want to display a drop down list and when i select some option from  
the drop down list i want to display all the records under that selected  
category in the “SAME PAGE”…

eg …

\<%= collection\_select(:question,:subject\_id ,@subject, :id, :name) %\>

when i choose a subject i should, display all the questions under that  
subject in the same page.I am new to rails.Can anyone please help me  
out…

Thanks in advance

---

<div class="post-metadata">

**Author:** ![subashinikumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/0ea827/32.png) [@subashinikumar](https://www.ruby-forum.com/u/subashinikumar)\
**Post date:** [September 23, 2009, 11:55am UTC](https://www.ruby-forum.com/t/collection-text-onchange-event/175984/2 "2009-09-23T11:55:42Z")

</div>

Hi

```
Have a look at observe_field

```

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

Sijo

---

<div class="post-metadata">

**Author:** ![subashinikumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/0ea827/32.png) [@subashinikumar](https://www.ruby-forum.com/u/subashinikumar)\
**Post date:** [September 23, 2009, 2:02pm UTC](https://www.ruby-forum.com/t/collection-text-onchange-event/175984/3 "2009-09-23T14:02:58Z")

</div>

Sijo Kg wrote:

> Hi
> 
> ```
> Have a look at observe_field
> 
> ```
> 
> [http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001654](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001654)
> 
> Sijo

Hi, i tried like this,

View page:

\<%= collection\_select(:question,:subject\_id ,Subject.all, :id, :name )  
%\>  
\<%= observe\_field ‘question\_subject\_id’,  
:url =\> {:controller=\>‘question’,:action =\> ‘subject\_action’}, :with  
=\> ‘subject\_id’ %\>

Controller:

i tried checking if it comes to the controller… the controller method  
is not even called. Please help me to find the mistake

def subject\_action  
render :update do |page|  
page.alert “hello from update items call!!”  
end  
end
