Setting a form input value with Javascript - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Setting a form input value with Javascript

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(){//from   w ww  . ja va  2s . c om
    x = document.getElementsByTagName('form');
    console.log('going '+x[0].direction.value);
}

      </script> 
   </head> 
   <body> 
      <form action="server.pl" method="POST"> 
         <input type="hidden" name="direction" value="forward"> 
      </form>  
   </body>
</html>

Related Tutorials