我正在學習軌道上的紅寶石。在我的項目 中,我使用了collection_select。我的代碼是collection_select onchange事件和選定的紅寶石軌道上
<%= collection_select(:sport_name,count,Sport.find(:all, :order => 'id'), :id, :sport_name, {} ,
{:selected => ps.sport.id,
:include_blank => "Select Sport",
:onchange => "hidvalue("+ps.sport.id.to_s+","+count.to_s+")",
:style => "margin:1px 0 0;width:210px;" }) %>
onchange
作品 - selected
不起作用
如果我不是做
<%= collection_select(:sport_name,count,Sport.find(:all, :order => 'id'),:id, :sport_name,
{:selected => ps.sport.id,
:include_blank => "Select Sport",
:onchange => "hidvalue("+ps.sport.id.to_s+","+count.to_s+")" },
{:style => "margin:1px 0 0;width:210px;" }) %>
onchange
不起作用,但selected
作品。我想一起使用onchange
和selected
。這段代碼有什麼問題?
你的onchange函數應該做什麼? –
用於將選定值保存到隱藏字段。 – tinzawtun