<html> <head> <title>Dynamically Generated HTML</title> <script language="JavaScript"> function initializeDiv() { div = document.getElementById("testdiv") } function insertElement() { var tagIX = document.forms["genform"].elements["elementType"].selectedIndex; var tagName = "p"; if(tagIX == 1) tagName = "h1"; else if(tagIX == 2) tagName = "blockquote"; else if(tagIX == 3) tagName = "pre";
var text = document.forms["genform"].elements["ta"].value; var newElement = document.createElement(tagName); var newText = document.createTextNode(text); newElement.appendChild(newText); div.appendChild(newElement); }