Great! I took the liberty of rewriting it more like I might do it. If you have questions about it or other stuff, feel free to ask:
Code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name="pform" onsubmit="myfunc(); return false;">
"Hello World"'s to add (integer only, greater than 0):<br>
<input type="text" name="howmany" pattern="[1-9]{1}[0-9]*" required> <!-- pattern requires an integer greater than 0 -->
<input type="submit" value="submit">
<p><input type="reset" value="clear" onclick="clearOutput(); return true;"></p>
</form>
<div id="output"></div>
<script>
function myfunc(){ // error checking (pareseInt, !isNaN and > 0) only for browsers that do not support the pattern attribute
var pp = parseInt(+document.forms.pform.howmany.value + 1), op = document.getElementById('output');
if(!isNaN(pp) && pp > 0){
while(--pp){
op.appendChild(document.createTextNode("Hello World"));
op.appendChild(document.createElement("br"));
op.appendChild(document.createTextNode("\n"));
}
}
}
function clearOutput(){
var op = document.getElementById('output');
while(op.firstChild){
op.removeChild(op.firstChild);
}
}
</script>
</body>
</html>
Bookmarks