I would like to get selected options to javascript, then create array with the option text.
This is what i did for now:
function selectMonthOnChange(month) {
var selectedMonths = [];
var selMonths = $('#sel_Months option:selected');
$(selMonths).each(function(k) {
selectedMonths.push(month.options[k].text);
});
console.log(selectedMonths);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select onchange="selectMonthOnChange(this)" id="sel_months" multiple="multiple ">
<option value="1 ">Jan</option>
<option value="2 ">Feb</option>
<option value="3 ">Mar</option>
...
<option value="12 ">Dec</option>
</select>
I want output (example, depends of selected months):
['Feb', 'May', 'Dec'];
I know, i'm doing something stupid and the answer is superb easy :) - gosh, I should take a break...