Javascript examples for DOM HTML Element:Select
Get selected value from <select> via selectedIndex
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/* w w w . ja v a2 s.co m*/ var oS = document.getElementById("my_select"); console.log(oS.options[oS.selectedIndex].value); }); </script> </head> <body> <select id="my_select"> <option value="1">Foo</option> <option value="2">Bar</option> <option selected>Bork</option> <option value="3">Hey!</option> </select> </body> </html>