Set input from <input> tag - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form Event

Description

Set input from <input> tag

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script>
     function myFunction()/*  ww w.ja  v a  2 s.c  o m*/
     {
       var a = document.getElementById("txt_1").value;
       document.getElementById("demo").innerHTML = a;
     }
    
      </script> 
   </head> 
   <body> 
      <form> 
         <input type="text" id="txt_1" name="txt_1"> 
         <input type="button" onclick="myFunction()" value="Click me"> 
      </form> 
      <p id="demo"></p>  
   </body>
</html>

Related Tutorials