# Search according to drop-down list

**URL:** <https://www.ruby-forum.com/t/search-according-to-drop-down-list/144021>\
**Category:** Rails\
**Created:** [July 24, 2008, 6:36pm UTC](https://www.ruby-forum.com/t/search-according-to-drop-down-list/144021 "2008-07-24T18:36:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 24, 2008, 6:36pm UTC](https://www.ruby-forum.com/t/search-according-to-drop-down-list/144021/1 "2008-07-24T18:36:05Z")

</div>

Hi, currently I have two separate search fields. One searches the  
paginated model and the other searches a user model:

\<% form\_for :post, :method =\> ‘get’ do %\>

\<%= collection\_select(:post, :id, @posts, :id, :title, options ={:prompt  
=\> “-Select categories-”}, :class=\>“category\_dropdown\_list”) %\>

\<%= text\_field\_tag :search, params[:search] %\>  
\<%= submit\_tag “Search”, :name =\> nil %\>  
\<% end %\>

\<%= observe\_field 'search\_form', :frequency =\> 0.5, :url =\> { :controller =\> 'auth\_user', :action =\> 'get\_results' }, :loading =\> "Element.show('indicator\_gif\_id')", :complete =\> "Element.hide('indicator\_gif\_id')", :with =\> "'search\_text=' + escape(value)" %\>

I have two main questions:

1. How would I observe the collection\_select and depending on what is  
selected, run x or y action (automatically)
2. How would I merge the two inputs (I want one input that gets observed  
to act as a ‘live search’)

Thanks!
