I want to fetch the value for which option is selected in the select_layer
. I think passing some functions to onChange
will work, but I cannot figure out how.
var identifier_dropdown = "<select class='form-select' id='select_layer'>"+
"<option selected>Open this select menu</option>"
for(let i=0;i<checkedLayers ;i++) {
identifier_dropdown += "<option value='"+(i)+"' >"+checkedLayersTitles[i]+"</option>"
}
identifier_dropdown += "</select>"
Try to use eventListener
:
let mySelect = document.querySelector('#select_layer');
mySelect.addEventListener('change', e => {
let selectedValue = mySelect.value;
// do some stuff here
});