I have the next code to display my countries table in a select box:
f.select("country_id", Country.all.collect {|p| [ p.name, p.id ] }, {:include_blank => 'Select a Country'})
and i want to set an 'onchange' action when a country es selected... I've tried:
f.select("country_id", Country.all.collect {|p| [ p.name, p.id ] }, {:include_blank => 'Select a Country',:onchange=>"alert('foo')"})
but nothing happens....
any help on this?
Thanks. Mr. Nizzle
Hi format of this helper is
select(object, method, choices, options = {}, html_options = {})
so try
f.select("country_id", Country.all.collect {|p| [ p.name, p.id ] }, {:include_blank => 'Select a Country'},{:onchange=>"alert('foo')"})
and also check html output of your version
Formbuilder#select
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With