Get Select value on Change in JavaScript

To get select value on its change, add the onchange to its HTML element and run your code.

<select onchange="someFunction()" id="mySelect">

Example:

Change element text depending on the selected value.

<div id="pickedColor">Red</div><br>

<select onchange="getColor()" id="colorPicker">
    <option value="red">Red color</option>
    <option value="green">Green color</option>
</select>



<script>
    function getColor() {
        var color = document.getElementById('colorPicker').value;
        var result = 'Red';

        if(color == 'green') {
            result = 'Green';
        }

        document.getElementById('pickedColor').innerHTML = result;
    }
</script>

Output:

Red