I have a form in my view with two drop-down menus populated from db tables where I would like to automatically submit the form when the onchange event occurs in any drop-down list:
<%= form_for @products, url: products_path, method: :get do |f| %> <%= select('post', 'state', @suppliers.collect {|s| [s.supp_state, s.id]}) %> <%= select('post', 'category_id', @categories.collect {|c| [c.cat_name, c.id]}) %> <div class='actions inline'><%= f.submit 'GO!' %></div> <% end %>
I tried the options for the following, but I'm brand new in Ruby / Rails / JS .. so far no luck:
<%= select('post', 'state', @suppliers.collect {|s| [s.supp_state, s.id]}, :onchange => "this.form.submit()") %> <%= select('post', 'state', @suppliers.collect {|s| [s.supp_state, s.id]}, :input_html => {:onchange => "this.form.submit()") %>
Any advice is appreciated!
source share