How to auto-submit Rails formhelper, when onchange occurs on select dropdown (populated from DB)

孤人 提交于 2019-12-01 06:26:13

See documentation: http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-select

The arguments goes like this:

select(object, method, choices, options = {}, html_options = {})

:onchange belongs to html options thus you need to fix your select box to this:

select('post', 'state', @suppliers.collect {|s| [s.supp_state, s.id]}, :onchange => "this.form.submit()")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!