I have a rails form with 2 selects where one of them depends on the the selected value of the other. So if I have 3 users and 5 items per user, once a user is selected I want the items selection to contain only the items specific to that user. Sounds pretty straightforward but I'm having a very difficult time getting this working. Here's the code where instead of users and items I have vendor_identifier and app_identifier (so a vendor may have many apps for example). Thanks very much in advance for your help!!
<p>
<%= f.label :vendor_identifier %><br />
<%= f.select :vendor_identifier, User.find(:all, :order => "last_name, first_name").collect {|u| [(u.first_na开发者_JAVA技巧me + " " + u.last_name), u.userid]} %>
</p>
<p>
<%= f.label :app_identifier %><br />
<%= f.select :app_identifier, App.find(:all, :conditions => {:vendor_identifier => :userid } , :order => "name") %>
</p>
<p>
I've written a guide on updating a select box based on another which you may find helpful: http://ryanbigg.com/2008/05/updating-a-select-box-based-on-another
精彩评论