title: Rails: Calling JS function on form_for radio buttons
body: <p>I have a form_for with radio buttons, and I want to call a javascript function when the radio button is changed.</p>
  
  <p>The radio buttons are for Chapter's field 'type', of type boolean.</p>
  
  <pre><code>&lt;%= form_for([book.category, book, chapter], remote: true ) do |f| %&gt;
  
      &lt;%= f.radio_button :type, true, onKeyUp: "alert('hi')", checked: 'checked' %&gt; 
      &lt;%= f.label :type, 'Link' %&gt;
  
      &lt;%= f.radio_button :type, false, onKeyUp: "alert('hi')" %&gt; 
      &lt;%= f.label :type, 'Text' %&gt;
  
  &lt;% end %&gt;
  </code></pre>
  
  <p>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.</p>
  
  <p>Eventually I want to call a function that hides/shows other text fields, but I can't even get the alert to execute! </p>
  
  <p>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!</p>