NOTICE: This website is no longer updated or supported - as such many of the techniques used to build it may seem antiquated in the modern day. It is preserved for historical reasons only.
<!--</script>
function addText()/* create the string */
{
var theString,theElement,insertSpot;
var theString = document.createTextNode(document.testform.newtext.value);/* create the br element */
theElement = document.createElement("br");/* find the div tag and add the string and br */
insertSpot = document.getElementById("div1");//-->
insertSpot.appendChild(theString);
insertSpot.appendChild(theElement);
}
<form action="#" name="testform" id="testform"></body>
New text: <input type="text" name="newtext" id="newtext" /></form>
<input type="button" value="Add" onclick="addText()" />