I have a form_for with radio buttons, and I want to call a javascript function when the radio button is changed.
The radio buttons are for Chapter's field 'type', of type boolean.
<%= form_for([book.category, book, chapter], remote: true ) do |f| %>
<%= f.radio_button :type, true, onKeyUp: "alert('hi')", checked: 'checked' %>
<%= f.label :type, 'Link' %>
<%= f.radio_button :type, false, onKeyUp: "alert('hi')" %>
<%= f.label :type, 'Text' %>
<% end %>
I've tried onchange and onclick as well. I've tried adding a {} before the options, and I get an error from Rails that there are too many parameters.
Eventually I want to call a function that hides/shows other text fields, but I can't even get the alert to execute!
I'm sure this is something really simple, but I've been searching the internet for the answer to this for way too long. Thanks for your help!