0

I want to filter a drop list items depending on choice item from another drop list

<%= form_tag("/myAdmin", method: "post") do %>
    <%= label_tag(:role_id, "Role: ")%>
    <%= select_tag('Role', options_for_select(Role.all.map(&:name)))  %> <br/>
    <%= label_tag(:school_id, "School: ")%>
    <%= select_tag('School', options_for_select(School.all.map(&:name) )) %> <br/>
    <%= label_tag(:grade_id, "Grade: ")%>
    <%= @grade = Grade.all
        @grade1 = @grade.map {|a| if a.school_id == :school_id a}
        select_tag('Grade', options_for_select(@grade1.map(&:name) ))  %> <br/>

<%= submit_tag("Submit") %>
<% end %>

here's a form that contains 3 drop lists.

I want to filter the grade list according the chosen school..

The grade model has { school_id and name attributes } and the school model has { organization_id and name attributes }

how can I do this?

9
  • You have to do it on the client side, using javascript. Oct 29, 2015 at 10:04
  • I want to perform it using Erb not javascript Oct 29, 2015 at 10:06
  • But do you want to update grades when you select a school in the browser? Oct 29, 2015 at 10:06
  • yes, I wanna to update/filter the grade drop list after selecting the school Oct 29, 2015 at 10:10
  • 3
    This means you need to use javascript. Oct 29, 2015 at 10:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.