<select name="place" id="place" onchange="spk();">
<option></option>
<option value="1">California</option>
<option value="2">New York</option>
<option value="3">Las Vegas</option>
<option value="4">Texas</option>
<option value="5">Ohio</option>
</select>
<div id="speak"></div>
<script>
function spk(){
var b = document.getElementById("place");
var c = b.options[b.selectedIndex].value; // this shows the selected option's value
var d = b.options[b.selectedIndex].text; // this shows the selected option's text
var e = "You have selected ";
document.getElementById("speak").innerHTML = e.concat(d);
}
</script>
No comments:
Post a Comment