collection_select onchange-Ereignis und ausgewählte ruby on rails

Lerne ich ruby on rails. In meinem Projekt
Ich benutze collection_select. Mein code ist

<%= 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 funktioniert - selected funktioniert nicht

Wenn ich stattdessen tun

<%= 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 funktioniert nicht, aber selected funktioniert. Ich will onchange und selected zusammen. Was ist falsch an diesem code?

  • Was ist dein onchange-Funktion tun soll?
  • für das speichern von ausgewählten Wert hidden-Feld.
InformationsquelleAutor tinzawtun | 2012-10-17
Schreibe einen Kommentar