Add value from textbox to textarea on clicking a button.

Discussion in 'JavaScript' started by kaps, Apr 11, 2008.

  1. #1
    Hi all,

    Add value from textbox to textarea on clicking a button.

    Thanks
     
    kaps, Apr 11, 2008 IP
  2. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Script :
    
    <script type="text/javascript">
    function transferText()
    	{
    	document.getElementById("textareaInput").value += document.getElementById("txtInput").value;
    	}
    </script>
    
    HTML:
    And update the HTML code like this :

    
    <input id="txtInput" value="text" /> <input type="button" onclick="transferText();" />
    <textarea id="textareaInput">Lalala</textarea>
    
    HTML:
    Update the input id, textarea id and the button onclick event.

    Good luck :)
     
    Morishani, Apr 11, 2008 IP