Search code examples
javascriptjqueryhtmlbootstrap-selectpicker

Bootstrap Select Picker Issues


I am trying to get my Multi-Select to look like one of the examples I found here: https://silviomoreto.github.io/bootstrap-select/examples/. I have downloaded the SelectPicker.js from here: http://silviomoreto.github.io/bootstrap-select/. It is showing 2 boxes side-by-side and I can't get the generic looking one to disappear.

<html>
    <head>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    </head>
    <body class="container">
        <br/><br/><br/><br/><br/>
        <div class="container-fluid">
            <div class="form-group">
              <select class="selectpicker" id="rating" multiple data-selected-text-format="count > 3">
                <option>G</option>
                <option>PG</option>
                <option>PG-13</option>
                <option>R</option>
                <option>NC-17</option>
              </select>
            </div>
        </div>
        <hr/>
        <button onclick=doThis();>SUBMIT</button>    
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script src="../Documents/Movies_New/movies_ui/bootstrap/js/bootstrap-select.js"></script>
        <script type="text/javascript">
        $(document).ready(function() {
            $('.selectpicker').selectpicker();

            function doThis(){
                alert('Submit');
            }
        });
        </script>
    </body>
</html>

Select Picker HTML Example Select Picker HTML Example2


Solution

  • i think You are missing to link the bootstrap-select.css. i used it in your example..

    <html>
        <head>
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">
    
    <!-- Latest compiled and minified JavaScript -->
        </head>
        <body class="container">
            <br/><br/><br/><br/><br/>
            <div class="container-fluid">
                <div class="form-group">
                  <select class="selectpicker" id="rating" multiple data-selected-text-format="count > 3">
                    <option>G</option>
                    <option>PG</option>
                    <option>PG-13</option>
                    <option>R</option>
                    <option>NC-17</option>
                  </select>
                </div>
            </div>
            <hr/>
            <button onclick=doThis();>SUBMIT</button>    
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>
    
            <script type="text/javascript">
            $(document).ready(function() {
                $('.selectpicker').selectpicker();
    
                function doThis(){
                    alert('Submit');
                }
            });
            </script>
        </body>
    </html>