Closed EduVillas closed 1 year ago
Thats possible
If you want to apply it to every select element, and they're all basic dropdowns/selects (no search, etc) you can get every element and iterate over them like this:
const e = document.getElementsByTagName("select");
for (var i = 0; i < e.length; i++) {
NiceSelect.bind(e[i]);
}
I have one select that's slightly different, so I just added a condition within it.
function updateSelectFields() {
const e = document.getElementsByTagName("select");
for (var i = 0; i < e.length; i++) {
if ( e[i].classList.contains('searchable') ) {
NiceSelect.bind(e[i], {searchable: true, placeholder: 'Search'});
} else {
NiceSelect.bind(e[i]);
}
}
}
How to apply for 2 or more selects in a form like state and city?