dynamically showing data based on different selection

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. john@bioldata.com