<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title>Append text to textarea element</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript"> function addText(text) { var textarea = document.getElementById("ta"); textarea.value += text; } </script></head><body> <textarea name="msg" id="ta" rows="20" cols="30">This is the original text</textarea><br /> <button onclick="addText(' [this is added on at the end]');">Add some text</button></body></html>