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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
yoni.gross-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jun-11 05:34 UTC
Re: 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-NUCbmw9U4W9Wk0Htik3J/w@public.gmane.org
On Jun 11, 5:30 am, surfman
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> 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.
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---