<html>
<body>
Select your favorite fruit:
<select onchange="myFunction(this)">
<option>Apple</option>
<option>Orange</option>
<option>Pineapple</option>
<option>Banana</option>
</select>
<p id="demo"></p>
<script>
function myFunction(selTag) {
var x = selTag.options[selTag.selectedIndex].text;
document.getElementById("demo").innerHTML = "You selected: " + x;
}
</script>
</body>
</html>