# Select the item

**URL:** <https://www.ruby-forum.com/t/select-the-item/82893>\
**Category:** Rails\
**Created:** [January 22, 2007, 6:13am UTC](https://www.ruby-forum.com/t/select-the-item/82893 "2007-01-22T06:13:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dilip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/47e85d/32.png) [@dilip](https://www.ruby-forum.com/u/dilip)\
**Post date:** [January 22, 2007, 6:13am UTC](https://www.ruby-forum.com/t/select-the-item/82893/1 "2007-01-22T06:13:16Z")

</div>

hi  
i am new to ruby and i have one text box for search by the string in  
the text box  
insted of that i am trying to implement a drop down list,with the  
selected item in the drop down it should search. problem hear is that  
the search is not going by the item please help me

The code is:  
  
insted of this i tryied  
\<%= select\_tag ‘category’,options\_for\_select([[‘ALL  
RESIDENTIAL’],  
[‘ALL COMMERCIAL’],  
[‘Commercial Land’],  
[‘Industrial Building’],  
[‘Industrial Shed’],  
[‘Farm House’]], to\_s), :onchange =\>  
“content.category(this,notnull ) ;” %\>

please help me…  
Thank you.

---

<div class="post-metadata">

**Author:** ![dilip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/47e85d/32.png) [@dilip](https://www.ruby-forum.com/u/dilip)\
**Post date:** [December 12, 2008, 6:33am UTC](https://www.ruby-forum.com/t/select-the-item/82893/2 "2008-12-12T06:33:57Z")

</div>

hi ,

i want to do the same search for my applicaion.

presently i can search the database by typing the string in the search  
box.  
But now i want to provide a dropdown box of search parameters instead  
of typing.  
here my search application is usin ajax .

## take a look at my search code:

## in index.html.erb

Search:   
\<img id=“spinner” src=“/images/indicator.gif” style=“display: none;” /

> 

\<%= observe\_field 'search\_form', :frequency =\> 0.5, :update =\> 'results', :url =\> { :controller =\> 'streams', :action=\> 'get\_results' }, :with =\> "'search\_text=' + escape(value)", :loading =\> "document.getElementById ('spinner').style.display='inline'", :loaded =\> "document.getElementById('spinner').style.display='none'" %\> ------------------------------------------------------------------------------- the search mthod defined in controller is --------------------------------------------

def get\_results  
if request.xhr?  
if params[‘search\_text’].strip.length \> 0  
terms = params[‘search\_text’].split.collect do |word|  
“%#{word.downcase}%”  
end  
if blank?  
flash[:notice] = ‘Stream was successfully updated.’  
else  
@streams = Stream.find\_tagged\_with(params[:search\_text])  
end  
end  
render :partial =\> “search”  
else  
redirect\_to :action =\> “index”  
end  
end

Can you help me hoe can i do this.

thnaks for any suggetions and help

regards  
Srikanth.

On Jan 22 2007, 10:13 am, Dilip Bv [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
