Grabbing value and appending to textarea with Javascript - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

Grabbing value and appending to textarea 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">
function doMagic(){//w ww.  j  a v  a 2s . c  o m
    var homeTown = document.getElementById("hometown").value;
    document.getElementById("comment").value += homeTown;
}

      </script> 
   </head> 
   <body> 
      <input type="text" name="hometown" id="hometown" size="22"> 
      <textarea name="comment" id="comment"></textarea> 
      <input type="submit" onClick="doMagic();">  
   </body>
</html>

Related Tutorials