1<!DOCTYPE html>
2<html>
3<body>
4
5<form>
6 Select your favorite browser:
7 <select id="myList" onchange="myFunction()">
8 <option></option>
9 <option>Google Chrome</option>
10 <option>Firefox</option>
11 <option>Internet Explorer</option>
12 <option>Safari</option>
13 <option>Opera</option>
14 </select>
15<p>Your favorite browser is: <input type="text" id="demo" size="20"></p>
16</form>
17<script>
18function myFunction() {
19 var mylist = document.getElementById("myList");
20 document.getElementById("demo").value = mylist.options[mylist.selectedIndex].text;
21}
22</script>
23</body>
24</html>