Forum: Ruby on Rails select the item

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
84b78951fdd827da337a4491c08aab85?d=identicon&s=25 Dilip Bv (dilip)
on 2007-01-22 06:13
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:
<input type="text" name="query" value="<%= h @query %>" /></h4>
 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.
E38118c6d20b4544e424fd700571e090?d=identicon&s=25 srikanth (Guest)
on 2008-12-12 06:33
(Received via mailing list)
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: <input type="category" id="search_form" name="search" />
<img id="spinner" src="/images/indicator.gif" style="display: none;" /
>
<div id="results"></div>
<%= 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 <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.