Dependency within form

Is there any way to have one drop-down collection dependent on another
within a form? E.g.

<% form_for @lab, :html => { :multipart => true } do |f| %>

<%= f.collection_select :lab_desc_id, LabDesc.find_main, :id, :name %> <%= f.collection_select :unit_id, LabDesc.units( ??? ), :id, :units %> <% end %>

So that ??? “knows” the id that was chosen in the first
collection_select?

Many TIA,
Craig

Dudebot wrote:

Is there any way to have one drop-down collection dependent on another
within a form? E.g.

<% form_for @lab, :html => { :multipart => true } do |f| %>

<%= f.collection_select :lab_desc_id, LabDesc.find_main, :id, :name %> <%= f.collection_select :unit_id, LabDesc.units( ??? ), :id, :units %> <% end %>

So that ??? “knows” the id that was chosen in the first
collection_select?

Many TIA,
Craig

I’m pretty sure that the last time this question was asked, the answer
was “Javascript”. Let the answer to the first one do an AJAX load of the
second one.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs