Using onChange in bootstrap multiselect
I changed the onChange
as follows. Now it fires but it only works for the first selection instead of for each selection.
onChange: function(option, checked, select) {
var opselected = $(option).val();
if(checked == true) {
if (opselected == '1') { $(".toggleG").toggle(); }
if (opselected == '2') { $(".toggleE").toggle(); }
if (opselected == '3') {
$(".toggleLAT").toggle();
$(".toggleLON").toggle();
}
if (opselected == '4') { $(".toggleLN").toggle(); }
if (opselected == '5') { $(".toggleTOD").toggle(); }
} else if(checked == false)
if (opselected == '1') { $(".toggleG").toggle(); }
if (opselected == '2') { $(".toggleE").toggle(); }
if (opselected == '3') {
$(".toggleLAT").toggle();
$(".toggleLON").toggle();
}
if (opselected == '4') { $(".toggleLN").toggle(); }
if (opselected == '5') { $(".toggleTOD").toggle(); }
}
}
This fixed it.
onChange: function(option, checked, select) {
var opselected = $(option).val();
if(checked == true) {
if (opselected == '1') { $(".toggleG").toggle(); }
if (opselected == '2') { $(".toggleE").toggle(); }
if (opselected == '3') { $(".toggleLAT").toggle(); $(".toggleLON").toggle();}
if (opselected == '4') { $(".toggleLN").toggle(); }
if (opselected == '5') { $(".toggleTOD").toggle(); }
} else if(checked == false)
if (opselected == '1') { $(".toggleG").toggle(); }
if (opselected == '2') { $(".toggleE").toggle(); }
if (opselected == '3') { $(".toggleLAT").toggle(); $(".toggleLON").toggle();}
if (opselected == '4') { $(".toggleLN").toggle(); }
if (opselected == '5') { $(".toggleTOD").toggle(); }
}
}