codice:
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function button1_onclick() {
var ntb = document.getElementById("text1").value;
if(!isNum(ntb))
{
alert("devi inserire un valore numerico");
}
else
{
var frm = document.getElementById("form1");
frm.innerHTML = "";
for(var i = 0; i < parseInt(ntb); i++)
{
addTextBox(frm, "text_" + i, "");
addLine(frm);
}
addSubmit(frm, "submit1", "Submit")
}
}
function isNum(arg)
{
return !isNaN(parseFloat(arg));
}
function addTextBox(form, key, value)
{
var input = document.createElement("input");
input.type = "text";
input.name = key;
input.value = value;
form.appendChild(input);
}
function addLine(form)
{
var input = document.createElement("hr");
form.appendChild(input);
}
function addSubmit(form, key, value)
{
var input = document.createElement("input");
input.type = "submit";
input.name = key;
input.value = value;
form.appendChild(input);
}
//-->
</SCRIPT>
</HEAD>
<BODY>
scegli quanti TextBox vuoi: <INPUT type="text" id=text1 name=text1>
<INPUT type="button" value="Button" id=button1 name=button1 LANGUAGE=javascript onclick="return button1_onclick()">
<HR>
<form id="form1" name="form1" action=? method=get>
</form>
</BODY>
</HTML>