Multipe Combo box Query System

Hi,

Anybody tell me, how i can implement multiple query system which is related hierarchically ?

Like

  1. Year,
  2. Files in that selected year.

I think you will need to be a lot more specific about your
requirement. I, for one, have little idea what you mean. If you are
just talking about related tables (has_many, belongs_to etc) then have
a look at the Rails Guide on ActiveRecord Relationships.

Colin

Dear Collin,

Sorry for failing in explaining the problem. I wish to apply like

  1. collection_select (country)
  2. collection_select (state)
  3. collection_select (city)

I need to give the query system hierarchically.

(Eg. select India -> then it should populate states in India-> select state tamilnadu-> it should populate cities in tamilnadu-> select madras-> It should get all params values as params[:country], :params[:state], :params[city]->@list = Table.find(conditions…params[:country], :params[:state], :params[city]))

This is the exact problem I need. In tutorials, this kind of hierarchal collection_select options are not available… If clear tutorials available kindly tell me… With Advanced Thanks.

You should look into:

http://stackoverflow.com/questions/575862/rjs-using-observe-field-on-select-tag

for info on how to use observe_field in combination with a select. I
just did a sursory review, and it looks like a decent solution
guideline.

...

1. collection_select (country)
2. collection_select (state)
3. collection_select (city)

...

(Eg. select India -> then it should populate states in India-

...
You can add onchange to 1 and 2 above, eg.
   collect_select( ...,
      :onchange=>
remote_function(:url=>controllers_path, :method=>:get,
                                   :with=>''
'country='+options[selectedIndex].value" ) )

where "controllers_path" is a path to an action that,

Or you could write some unobtrusive jQuery code to perform similarly.

Jeff

Dear Jeff,

Thank you very much… Excellent.

Ryan Bates did an excellent screencast that does exactly just that:
http://railscasts.com/episodes/88-dynamic-select-menus

Supposedly this plugin does the same thing
http://github.com/splendeo/dependent_select

Haven't tried it personally, so can't vouch for it.

-sunny
http://ezror.com