Set content to <option> element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Option

Description

Set content to <option> element

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <select id="MySelectBox"> 
         <option value="1" id="this_year"></option> 
         <option value="2" id="next_year"></option> 
      </select> 
      <script type="text/javascript">
var d = new Date();/* w ww  . j  a  va  2  s  .  com*/
var x = document.getElementById("this_year");
x.innerHTML=d.getFullYear(); 
var y = document.getElementById("next_year");
y.innerHTML=d.getFullYear()+1;

      </script>  
   </body>
</html>

Related Tutorials