Reputation: 1048
how can I display option value from the select list in my consol.log without selecting it twice. Now it works but I need to click twice to diplay it.
JS
function formatClick() {
screenName = document.getElementById("linkscreen").value;
console.log(screenName);
}
Upvotes: 0
Views: 34
Reputation: 67217
At this context, click
event seems inappropriate. Use change
event instead.
.. .. onchange="formatClick()">
And additionally, I would advise you to not to use an inline event handler. Use a dedicated event handler like below,
document.getElementById("linkscreen").addEventListener("change", formatClick, false);
Upvotes: 2