Hi Tz Le, On Tue, 2009-08-25 at 21:48 +0200, Tz Le wrote: > I am trying to create a view/form that has a dropdown > > <p> > <%= f.label :type_id%><br /> > <%= f.select :type_id,Type.all.collect{|c| [c.description,c.id]}, > :onchange=>"HERE I NEED TO DO SOMETHING WHAT?" %> > <!-- on change or on select show drop down for value otherwise > regular value --> > </p> > > Now when they change and the id is now 5 > HERE I NEED TO CHECK THE VALUE SELECTED BY THE FIRST SELECT > 1. How do I access the id of the first select and what was selected? > > I want to create: > <p> > <%= f.label :value %> > <%= f.select :value,Test.get_tests.all.collect{|c| > [c.description,c.test_id]} %> > </p> > > If its not 5 > I want > <p> > <%= f.label :value %><br /> > <%= f.text_field :value %> > > Please if you can tell me how to access the first select- do I set an > id? and what I do onchange since its in the same form a few lines down I > want to have a different field.
You need to put an observe_field on the first field that makes an ajax call to render a partial containing the second field with the appropriate choices based on the first selection. Try a google search on 'rails observe_field select'. HTH, Bill --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---