How do I get back on onChange all selected values in my multiselect dropdown. Used plugin here. Trying to use the following but I think I'm on the wrong track
$('#multiselect1').multiselect({
selectAllValue: 'multiselect-all',
enableCaseInsensitiveFiltering: true,
enableFiltering: true,
maxHeight: '300',
buttonWidth: '235',
onChange: function(element, checked) {
var brands = $('#multiselect1 option:selected');
var selection = [];
$(brands).each(function(index, brand){
selection.push(brand);
});
console.log(selection);
}
});
found it
$('#multiselect1').multiselect({
selectAllValue: 'multiselect-all',
enableCaseInsensitiveFiltering: true,
enableFiltering: true,
maxHeight: '300',
buttonWidth: '235',
onChange: function(element, checked) {
var brands = $('#multiselect1 option:selected');
var selected = [];
$(brands).each(function(index, brand){
selected.push([$(this).val()]);
});
console.log(selected);
}
});
In my case i was using jQuery validation rules with
submitHandler
function and submitting the data asnew FormData(form);
Get the multiple selected value and set to
new_branch
input value & while submitting the form get value fromnew_branch
Just replace
hidden
withtext
to view on the outputthe solution what I found to work in my case
more efficient, due to less DOM lookups:
In your Html page please add
In your ajax.js page please add
In your action.php page add