Release Input when you click Select

3

Hello, I have a question in my code. I need to click on a Select to display fields for entries. For example:

 <form role="form" class="form-horizontal">                                    
      <div class="form-group">
         <label class="col-md-3 control-label">Produto</label>
          <div class="col-md-3">                                        
           <select class="form-control select" name="tipo">
                  <option>Carro</option>
                  <option>Moto</option>
                  <option>Jetski</option>
                  <option>Barco</option>
           </select>
        </div>
   </div> 

When you select Car, for example, open these fields:

    <div class="col-md-6" nome"carro">                        
                        <div class="block">
                            <h4>Opcionais</h4>
                            <div class="panel panel-default">
                                <div class="panel-body">
                                <div class="form-group">
                                        <div class="col-md-4">                                    
                                        <label class="check"><input type="checkbox" name="airbag" class="icheckbox"/> Airbag</label>
                                        </div>

                                        <div class="col-md-4">   
                                        <label class="check"><input type="checkbox" name="freio_a_disco" class="icheckbox"/> Freio a disco</label>
                                        </div>

                                        <div class="col-md-4">   
                                        <label class="check"><input type="checkbox" name="abs" class="icheckbox"/> ABS</label>
                                        </div>

                                        <div class="col-md-4">   
                                        <label class="check"><input type="checkbox" name="cambio_manual" class="icheckbox"/> Câmbio manual</label>
                                        </div>

                                        <div class="col-md-4">   
                                        <label class="check"><input type="checkbox" name="cambio_automatico" class="icheckbox"/> Câmbio automático</label>
                                        </div>
                                       </div>
                                    </div>

                                </div>
                                </div>

I'll make the Checkbox fields for each Type (select category), for motorbikes, houses, cars, etc. My question is how do I insert the whole set by clicking Select.

    
asked by anonymous 30.08.2016 / 03:52

1 answer

2

You can use adapt Ajax below for this. Remember that by id and name in the fields:

<script>
$(document).ready(function() {
   $("#div_para_ocultar").hide()
     $('#tipo').on('change',function(){
         if( $(this).val()==="Carro"){
            $("#div_para_ocultar").show()
         } else if... {
            $("#div_para_ocultar_2").show()
        }
    });
});
</script>
    
30.08.2016 / 13:14