Reputation: 210
I am using multiselect in selectize.js, how do i get the vales from the select options: html:
<div class="selectBox1" multiple="multiple">
<select id="period">
<option value="day">Day</option>
<option value="week">Week</option>
<option value="month">Month</option>
<option value="year">Year</option>
</select>
select.js init:
$(document).ready(function($){
$('#period').selectize({
sortField: "text",
placeholder: "Select a Period..",
});
});
I tried to get the value by simply using this code:
var values = $('#period').val();
console.log(values)
but it returns an empty array. what can i do?
Upvotes: -1
Views: 251
Reputation: 141
Just add onChange
handler:
$(document).ready(function($){
$('#period').selectize({
sortField: "text",
placeholder: "Select a Period..",
onChange(value) {
console.log(value);
}
});
});
Upvotes: 0