get selected value on a dropdown field - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Select

Description

get selected value on a dropdown field

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){// w  w w. j av a2  s . c o m
console.log(document.getElementById('select').options[1].value)
    }

      </script> 
   </head> 
   <body> 
      <select id="select"> 
         <option value="A">A</option> 
         <option value="B">B</option> 
         <option value="C">C</option> 
      </select>  
   </body>
</html>

Related Tutorials