我的 Rails 应用程序中有以下视图:
<div class="row">
<div class="span11 center searchFieldContainer">
<div class="span3">
<%= collection_select :matchup, :player_1, Player.all, :id, :last_name, {}, { :multiple => false, class: "matchupSearchField", id: "player_1_search_field" } %>
</div>
<div class="span3">
<h2>VS</h2>
</div>
<div class="span3">
<%= collection_select :matchup, :player_2, Player.all, :id, :last_name, {}, { :multiple => false, class: "matchupSearchField", id: "player_2_search_field" } %>
</div>
</div>
<%= link_to "View Matchup",
findMatchup_path(:player_1 => **ID_OF_PLAYER_1**, :player_2 => **ID_OF_PLAYER_1**),
:method => :get, class: "my_class" %>
</div>
这是'/home.html.erb'的一部分,我的root_path。
如何将 link_to 中的ID_OF_PLAYER_1替换为上面 collection_select 中选择的玩家的 ID?我可以使用 jQuery 来获取该 collection_select 字段的值吗?
谢谢!