I have a bootstrap selectpicker and what I am trying to do is get multiple options selected once I load the page. I am passing in a string from a servlet to a script.
I have a selectbox in my html with an id, Project1, and class, selectBox.
In my script:
$(document).ready(function() {
$('.selectBox').selectpicker();
});
var index2="${projectindex}";
$('#Project1').selectpicker('val',index2);
projectindex is the variable being passed from the servlet (using jsp). I checked it and it passes correctly to something similar to this:
['project1' , 'project2']
These two are values in the select box, but they are not selected once the document loads. Can someone tell me what I did wrong?
Thanks for any help!