Use var in Javascript to define variable and set to input field - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form Event

Description

Use var in Javascript to define variable and set to input 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() {/*from  w  ww  . j a va 2 s .co  m*/

console.log("hi!")
var name = 'test';
//Sets the hidden value with "name"
document.getElementById('hidden').value= name;


    });

      </script> 
   </head> 
   <body> 
      <input id="hidden">  
   </body>
</html>

Related Tutorials