我有一個部分是使用下面的方法呈現一個選擇框:重用一個頁面上的諧音多次在Ruby on Rails的
<%= collection_select 'type', 'id', @types, "id", "name",
{:prompt => true},
{:onchange =>
remote_function(
:loading => "Form.Element.disable('go_button')",
:url => '/sfc/criteria/services',
:with => "'type_id=' + encodeURIComponent(value) + '&use_wizard=#{use_wizard}'"),
:class => "hosp_select_buttons"
} %>
這部分被使用在每一頁上2倍,但在一個點我需要獲得第一個選擇框的值。使用:
$('type_id')
返回第二個選擇框。有沒有辦法輕鬆找到第一個?我應該使用JavaScript解決這個問題還是通過重做我的部分?
注意:下拉列表會以單獨的形式呈現。