I need to re-write this code below to work in rails format. I alread googled, unsuccessfully.
<select id="ddlSelect">
      <option>Jobs</option>
      <option>Products</option>
      <option>Other</option>
    </select>
<input type="text" id="hdnPro" value="product" style='display:none'/>
$('#ddlSelect').on('change',function(){
   if($(this).val() == 'Products'){
        $('#hdnPro').show();
      }else{
        $('#hdnPro').hide();
      }
});
I need to convert this code above to work inside a rails framework.
In the view I tried this way, /app/vies/gastos/_form.html.erb:
 <div align="center">
  <%= form_for(@gasto) do |f| %>
    <div class="form-group">
      <div class="field" id="ddlSelect">
        <%= f.label "Tipo de Pagamento" %><br>
        <%= f.select_tag(:payment_type, options_for_select([['À vista', 1], ['À prazo', 2], ['Misto', 3]]), { include_blank: true } ) %>   
      </div>
      <div class="field" id="hdnPro" style='display:none'>
        <%= render 'payment_flows/form' %>
      </div> 
    </div>
  <% end %>
</div>
And the javascript file this way, in the location /app/assets/javascript:
$('#ddlSelect').change(function(){
  $ajax({
    $('#ddlSelect').('change',function(){
        if($(this).val() == 'À prazo'){
            $('#hdnPro').show();
        }else{
            $('#hdnPro').hide();
    })
  })
});
Sorry for my bad english.
 
     
    