Dynamically showing data based on different selection

suppose there is a selection list that has different selections, I want
to show different items to my users based on each different selection.

say, there is selection list that has breakfast, lunch, dinner, when a
user chooses breakfast, the page will show all items for breakfast, for
instance, bread, milk, sausage, when the user chooses lunch, the same
page will show beef, soup, noodles, etc.

is there any fast way to do this? thanks.

I have the same situation where the users selects a room, then
storage , then sub compartment each with it’s own unique dataset.
[Room]/ [Storage type]/ [Sub storage]/ [Substorage]/

The storage model uses the “acts_as_tree” for hierarchy.

it’s a patch (if there is a better way to do it I’ll be glad to
refactor it):

<% if !storages.empty?%>
<% type_url = "’/storages/get_selected_type/’ +
this[this.selectedIndex].value "%>
<% select_array = storages.collect {|storage| [ storage.type_and_name,
storage.id ]}%>
<%=select “storage”,“id”, select_array,
options = {:prompt => “- Select -”},
html_options={:onChange => "new Ajax.Request(#{type_url},
{ asynchronous:true,
evalScripts:true ,
onLoading:function(request){

Element.show(‘spinner_storage’);
Element.hide(‘storage_children’); },
onSuccess:function(request){

Element.hide(‘spinner_storage’)})"}%>
<%= spinner_tag(“spinner_storage”) %>
<%else%>
selected
<%end%>

I am creating an Ajax request on the change event, this calls returns
the next selection dropdown.
(p.s. the spinner tag is just an helper method to return a spinner).

Hope this helps.
Jonathan Gross.
[email protected]