"Load an array into select tag"
Bootstrap 3.0.0 Snippet by hstev

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <div class="col-md-4 col-md-offset-4"> <h1 class="page-header">Load an array into select tag <code>Example</code></h1> <select id="mySelect" class="form-control"> <option value="empty">empty</option> </select> </div> </div> </div>
var myArray = ["item1", "item2", "item3", "itemn"]; $(document).ready(function(){ var collect = ''; for(var i = 0; i<myArray.length;i++){ collect += '<option value="'+i+'">'+myArray[i]+'</option>'; } document.getElementById("mySelect").innerHTML = collect; })

Related: See More


Questions / Comments: