0

ラジオ ボタンがあります。最初のバリアントを選択する<%= f.text_field :price %>と利用可能になり、2 番目のバリアント<%= f.text_field :price %>を選択すると利用できなくなります

<%= f.radio_button :price, true %><%= f.label :price %>
    <%= f.text_field :price %>
    <%= f.radio_button :price, false %><%= f.label :price %>
    <%= radio_button_tag(:price, "price") %>

どうすればできますか?

4

1 に答える 1

0

次のスクリプトを使用することをお勧めします。

<%= f.radio_button :price, false %><%= f.label :price %>
    <%= f.text_field :price %>
    <%= f.radio_button :price, true %><%= f.label :price %>
    <script>$(document).ready(function(){
      $('#post_price_true').change(function(){
        $('#post_price').attr('disabled','disabled');
      });
      $('#post_price_false').change(function(){
        $('#post_price').removeAttr('disabled');
      });
      });</script>

odin nol' v pol'zu zritelei

于 2013-11-11T15:55:58.713 に答える