Release Input by clicking Select

Asked

Viewed 118 times

3

Hello, I have a question in my code. I need that when clicking a Select is displayed 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 selecting 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 will do the Checkbox fields for each Type (select category), for bikes, houses, cars, etc. My question is how I insert the whole set by clicking on Select.

  • Did my answer help you? If so, mark it as accepted :)

  • Hello Diego, It worked, thank you very much!

  • Then you can accept my answer below :)

1 answer

2


You can use to adapt the Ajax below for this. Remember if 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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.