0

I have a two f.select fields in my form with the same object id. I am changing these fields by selecting the parent field using javascript and CSS.

<%= f.label :Service_Phase, 'Service Phase' %>    
<%= f.select :Service_Phase, [], { :prompt => 'None' }, class: 'select_phase', disabled: 'disabled' %>
<%= f.select :Service_Phase, (1..52), { :prompt => 'Select Week' }, class: 'select_week' %>
<%= f.select :Service_Phase, (1..12), { :prompt => 'Select Month' }, class: 'select_month' %>

I want to display the select box disabled with the text 'NONE' by default and will change the select_field by the parent select field value. Is it any other neat way to do this in rails? Because when i try to the check the value after selected the value of week in console, its display the empty string. I don't know where am doing wrong and how can I correct this? Thanks in advance.

4

1 回答 1

0

我认为你最好只用 javascript/jquery 来做这件事。我不相信 rails 有一种内置的方式来启用基于第一个的辅助选择字段。

于 2013-04-29T15:54:40.560 回答