I have a dropdown list in html
<select id="dropdown">
<option value="text">Text</option>
<option value="graphic">Graphic</option>
<option value="formula">Formula</option>
<option value="title">Title</option>
</select>
I am trying to get the selected option from the menu by calling a function.
I tried two options:
1.I tried using onclick -the problem with this is, my function call is triggered when I click on the dropdown button but before any option is selected.
2.so I used onchange to call my function, but when I use this,the function call is not triggered if i want to use the same option in a row, because as the name suggests, the function is called only when the option is changed.
Is there any other way how i can get the selected option?
this is my script-
...
document.addEventListener('DOMContentLoaded',function() { document.querySelector('select[name="zonelist"]').onclick=getSelectedTextValue;
},false);
...
function getSelectedTextValue(){}
...