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 ) ;” %>
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 .
<%= 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