title: Rails radio yes/no buttons to show more fields
body: <p>I have a <code>item.rb model</code> with yes or no <code>radio buttons</code>:</p>
  
  <pre><code>enum stock: { "No": "1", "Yes": "2" }
  </code></pre>
  
  <p>and in the view:</p>
  
  <pre><code>&lt;%= f.collection_radio_buttons :stock, Item.stock, :first, :first %&gt;
  </code></pre>
  
  <p>and if I click on yes I want more fields to show up, which I have inside this:</p>
  
  <pre><code>&lt;div id="ifYes" style="display:none"&gt;
  &lt;/div
  </code></pre>
  
  <p>I'm trying to use this javascript in order to achieve that:</p>
  
  <pre><code>  &lt;script type="text/javascript"&gt;
  
        function yesnoCheck() {
            if (document.getElementById('yesCheck').checked) {
                document.getElementById('ifYes').style.display = 'block';
            }
            else document.getElementById('ifYes').style.display = 'none';
  
        }
  
    &lt;/script&gt;
  </code></pre>
  
  <p>with this but nothing is happening:</p>
  
  <pre><code>&lt;%= f.collection_radio_buttons :stock, Item.stock, :first, :first, onclick:"javascript:yesnoCheck();", :id=&gt;"yesCheck" %&gt;
  </code></pre>
  
  <p>Any idea on how I can make this work?</p>
  
  <p><strong>Update 1</strong></p>
  
  <p>Now I'm doing this and the when I click either yes or no the content inside <code>&lt;div id="ifYes" style="display:none;"&gt;&lt;/div&gt;</code> is showing.</p>
  
  <pre><code>&lt;%= f.collection_radio_buttons :stock, Item.stock, :first, :first, onChange:"getValue(this)" %&gt;
  
  
  
   &lt;script type="text/javascript"&gt;
  
        $(document).ready(function(getValue){
            $("input[type=radio]").change(function(){
                $('#ifYes').show();
            });
        });
  
    &lt;/script&gt;
  </code></pre>
  
  <p>But how can hide the fields if I click on no?</p>