Retrieving selected string from a combobox

Jan 21 2019 2:37 AM
Hi folks
 
I've written this little snippet to help simplify my question.  Basically, on the combobox change I'm displaying the value of the selection - so 21 if I select BMW.  How could I display BMW instead? 
<select id="myWeeCombo" onchange="myFunction()">
    <option value="11">Audi</option>
    <option value="21">BMW</option>
    <option value="31">Mercedes</option>
    <option value="41">Volvo</option>
</select>
<p id="demo"></p>
<script>
    function myFunction()
   {
        var x = document.getElementById("myWeeCombo").value;
        document.getElementById("demo").innerHTML = "You selected: " + x;
    }
</script>

Answers (5)