레일에서 루비를 배우고 있습니다. 내 프로젝트에서 나는 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
일을 할 경우
작동하지 않습니다 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
작품이다. onchange
과 selected
을 함께 사용하고 싶습니다. 이 코드의 문제점은 무엇입니까?
수행해야 할 onchange 함수는 무엇입니까? –
숨겨진 필드에 선택한 값을 저장합니다. – tinzawtun