title: disable input on checkbox in rails app
body: <p>I have a date input dropdown on a form in my rails application.</p>
  
  <p>I'd like there to be a checkbox that- when checked/selected by the user- will (#1) disable the date input and (#2) populate the date input with the current date.</p>
  
  <p>I've looked at previous SO answers to get an idea of how to do this and here's what I tried to accomplish #1:</p>
  
  <pre><code>app/assets/javascripts/application.js
  
   //= require jquery
   //= require bootstrap
   //= require jquery_ujs
   //= require turbolinks
   //= require_tree .
  
  $(document).on('change', '#availableNow', function(){
      debugger;
      if($(this).prop('checked')){
          $('#fromDatePicker').attr('disabled', 'disabled');
      } else {
          $('#fromDatePicker').removeAttr('disabled');
      }
  });
  </code></pre>
  
  <p>In the form...</p>
  
  <pre><code>app/views/apartments/_form.html.erb
  
     &lt;div class="field"&gt;
        &lt;%= f.label :available_now %&gt;
        &lt;%= f.check_box :available_now, id:"availableNow" %&gt;
      &lt;/div&gt;
      &lt;div class="field"&gt;
        &lt;%= f.label :to_date %&gt;&lt;br&gt;
        &lt;%= f.date_select :to_date, {:include_blank =&gt; true, :default =&gt; nil, :start_year =&gt; Date.today.year, :end_year =&gt; Date.today.year + 4, :order =&gt; [:month, :day, :year] }, id:"fromDatePicker" %&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Rails generates 3 dropdown menus for the date picker (day, month &amp; year). Only month (the first dropdown) is disabled when the box is checked.</p>
  
  <p>Any ideas how to get the checkbox functionality to work for all the dropdowns?</p>
  
  <p>Any idea how to "grey out" the dropdowns once they are disabled?</p>
  
  <p>Thanks in advance!</p>