title: Calling a JavaScript function during onchange of a select box
body: <p>In my view, I have the following:</p>
  
  <pre><code>&lt;%= select("event", :event_id, events_ids_titles_hash, { :include_blank =&gt; true, :onchange =&gt; "alert_me_test()" }) %&gt;
  </code></pre>
  
  <p>alert_me_test() is:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    function alert_me_test()
    {
        alert ("this is a test")
    }
  &lt;/script&gt;
  </code></pre>
  
  <p>The dropdown is appearing fine, but when I select from it, nothing happens. I'm expecting an alert box with "this is a test" in it.</p>
  
  <h1>The Edit case:</h1>
  
  <p>When I'm doing an edit, I have the following code:</p>
  
  <pre><code>&lt;% if @panel.event_id %&gt;
    &lt;%= select("panel", :event_id, events_ids_titles_hash, {:selected =&gt; @panel.event_id}, { :include_blank =&gt; true}) %&gt;
  </code></pre>
  
  <p>My IDE (RubyMine) does not want to accept the "onchange" as an additional argument, and putting it inside one of the :selected or :include_blank argument hashes does not produce an error, but it does not work either</p>
  
  <h1>What ended up working for both new and edit:</h1>
  
  <pre><code>&lt;% if @panel.event_id %&gt;
      &lt;%= 'Event is ' + events_ids_titles_hash.key(@panel.event_id) %&gt;
      &lt;%= select("panel", :event_id, events_ids_titles_hash, {:selected =&gt; @panel.event_id}, { :include_blank =&gt; true, :onchange =&gt; "alert_me_test()"}) %&gt;
  &lt;% else %&gt;
      &lt;%= 'Select Event from list' %&gt;
      &lt;%= select("event", :event_id, events_ids_titles_hash, { :include_blank =&gt; true }, { :onchange =&gt; "alert_me_test()" }) %&gt;
  &lt;% end %&gt;
  </code></pre>