I've seen a bunch of examples that are close, but none that are right on.
I'm building a program that is an HTA form where people can enter multiple lines of similar data (ex. mailing addresses). The number of lines that the user will enter is determined by an input box that receives a number:
<html>
<head>
<title>Data Entry Application</title>
<hta:application id = "ExampleHTA" singleInstance = "yes" icon = "macexp.ico" border = "thin" minimizeButton = "no" maximizeButton = "no" scroll = "yes" />
<script language="javascript" type="text/javascript">
function numOfLines(choice)
{
for(var i = 0; i < choice; ++i)
{
document.getElementById("addy_lines").innerHTML = "<br />Name: <input type='text' id='Name' size=50 maxlength=50 /> Address: <input type='text' id='Address' size=50 maxlength=50 /> City: <input type='text' id='City' size=15 maxlength=15 /> State: <input type='text id='State' size=2 maxlength=2 /> Zip Code: <input type='text' id='Zip' size=5 maxlength=5 />";
}
}
</script>
</head>
<body>
<form>
Number of Address Lines: <input type="text" id="AddyLines" size=2 maxlength=2 onChange="numOfLines(this.value);">
<div id="addy_lines"></div>
</form>
</body>
</html>
http://jsfiddle.net/isherwood/r9KEH/
When the user enters a number in the AddyLines input box, the same number of lines should appear in the div id="addy_lines" section.
Example: The user enters 5, then five input lines should be created. Currently, only one address input line gets created within the div tags.