title: collection_select onchange event and selected ruby on rails
body: <p>I am learning ruby on rails. In my project
  I use collection_select. My code is                                                               </p>
  
  <pre><code>&lt;%= collection_select(:sport_name,count,Sport.find( :all, :order =&gt; 'id' ), :id, :sport_name, {} ,
      {:selected      =&gt; ps.sport.id,
       :include_blank =&gt; "Select Sport",
       :onchange      =&gt; "hidvalue("+ps.sport.id.to_s+","+count.to_s+")",
       :style         =&gt; "margin:1px 0 0;width:210px;" }) %&gt;
  </code></pre>
  
  <p><code>onchange</code> works - <code>selected</code> doesn't work</p>
  
  <p>If I instead do</p>
  
  <pre><code>&lt;%= collection_select(:sport_name,count,Sport.find( :all, :order =&gt; 'id' ),:id, :sport_name,
      {:selected      =&gt; ps.sport.id,
       :include_blank =&gt; "Select Sport",
       :onchange      =&gt; "hidvalue("+ps.sport.id.to_s+","+count.to_s+")" },
      {:style         =&gt; "margin:1px 0 0;width:210px;" }) %&gt;  
  </code></pre>
  
  <p><code>onchange</code> doesn't work, but <code>selected</code> works. I want to use <code>onchange</code> and <code>selected</code> together. What is wrong with this code?</p>