Select in bootstrap

2

I try to include a field within a form with the selectpicker class of bootstrap but the style does not add style or live search, any idea of why? this is my code

These are the libraries that I use, only jquery I have it remotely bootstrap I have it locally

    <link href="style/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://code.jquery.com/jquery.js"></script>
    <script src="style/bootstrap/js/bootstrap.min.js"></script>

This is the form     

   <div class="form-group">
   <label for="exampleInputEmail1">Nombre</label>
   <input type="email" class="form-control" name="nombre" placeholder="Email">
   </div>

   <div class="form-group">
      <label for="exampleInputEmail1">Apellidos</label>
      <input type="email" class="form-control" name="nombre" placeholder="Email">
   </div>

    <div class="form-group">                                        
      <label for="exampleInputEmail1">Area</label><br/>
      <select class="selectpicker" data-live-search="true">
      <option data-tokens="ketchup mustard">Hot Dog, Fries and a Soda</option>
      <option data-tokens="mustard">Burger, Shake and a Smile</option>
      <option data-tokens="frosting">Sugar, Spice and all things nice</option>
      </select>                                          
     </div>

     <div class="form-group">
         <label for="exampleInputEmail1">Corrre electronico</label>
         <input type="email" class="form-control" name="apellidos" placeholder="Email">
     </div>


      <div class="form-group">
          <label for="exampleInputPassword1">Password</label>
           <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
          <input type="hidden"  name="tipo" value="1">                                                                                                                    
      </div>

    <button type="button" class="btn btn-default">Cancelar</button>
     <button type="submit" class="btn btn-success">Registrarme</button>
</form><!-- Cierrra form registro -->
    
asked by Missael Armenta 01.07.2016 в 00:00
source

2 answers

1

If you say that the bootstrap selectpicker does not appear correctly, it is because you have not added the references of the library, I leave you the same code but with the references of the library.

<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"></script>
<form action="Registro" method="post"><!-- registro -->

   <div class="form-group">
   <label for="exampleInputEmail1">Nombre</label>
   <input type="email" class="form-control" name="nombre" placeholder="Email">
   </div>

   <div class="form-group">
      <label for="exampleInputEmail1">Apellidos</label>
      <input type="email" class="form-control" name="nombre" placeholder="Email">
   </div>

    <div class="form-group">                                        
      <label for="exampleInputEmail1">Area</label><br/>
      <select class="selectpicker" data-live-search="true">
      <option data-tokens="ketchup mustard">Hot Dog, Fries and a Soda</option>
      <option data-tokens="mustard">Burger, Shake and a Smile</option>
      <option data-tokens="frosting">Sugar, Spice and all things nice</option>
      </select>                                          
     </div>

     <div class="form-group">
         <label for="exampleInputEmail1">Corrre electronico</label>
         <input type="email" class="form-control" name="apellidos" placeholder="Email">
     </div>


      <div class="form-group">
          <label for="exampleInputPassword1">Password</label>
           <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
          <input type="hidden"  name="tipo" value="1">                                                                                                                    
      </div>

    <button type="button" class="btn btn-default">Cancelar</button>
     <button type="submit" class="btn btn-success">Registrarme</button>
</form><!-- Cierrra form registro -->
    
answered by 01.07.2016 / 00:09
source
0

You still have to add the libraries, in the documentation they show the external links so that they work correctly.

These would be the links you need:

CSS

<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css" rel="stylesheet"/>

JS

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"></script>  

Here I show your code with the select working:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"></script>

<form action="Registro" method="post"><!-- registro -->

   <div class="form-group">
   <label for="exampleInputEmail1">Nombre</label>
   <input type="email" class="form-control" name="nombre" placeholder="Email">
   </div>

   <div class="form-group">
      <label for="exampleInputEmail1">Apellidos</label>
      <input type="email" class="form-control" name="nombre" placeholder="Email">
   </div>

    <div class="form-group">                                        
      <label for="exampleInputEmail1">Area</label><br/>
     <select class="selectpicker" data-live-search="true">
      <option data-tokens="ketchup mustard">Hot Dog, Fries and a Soda</option>
      <option data-tokens="mustard">Burger, Shake and a Smile</option>
      <option data-tokens="frosting">Sugar, Spice and all things nice</option>
    </select>
                                         
     </div>

     <div class="form-group">
         <label for="exampleInputEmail1">Corrre electronico</label>
         <input type="email" class="form-control" name="apellidos" placeholder="Email">
     </div>


      <div class="form-group">
          <label for="exampleInputPassword1">Password</label>
           <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
          <input type="hidden"  name="tipo" value="1">                                                                                                                    
      </div>

    <button type="button" class="btn btn-default">Cancelar</button>
     <button type="submit" class="btn btn-success">Registrarme</button>
</form><!-- Cierrra form registro -->

I recommend you try the Select2 which in my opinion is a bit more complete in some aspects and is used the same way, I hope it serves you

    
answered by 01.07.2016 в 00:21