codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
<script type="text/javascript">
window.onload = function()
{
var lista = document.getElementById("Select1");
lista.focus();
lista.onchange = Select1_onchange;
}
function Select1_onchange()
{
var target = document.getElementById("div1");
for(var i = target.childNodes.length - 1; i >=0 ; i--)
target.removeChild(target.childNodes[i]);
var n = this.options[this.selectedIndex].value;
for(var i = 0; i < n; i++)
{
var t = creaTextBox();
t.id = "textbox_" + i;
t.name = t.id;
target.appendChild(t);
var br1 = document.createElement("br");
var br2 = document.createElement("br");
target.appendChild(br1);
target.appendChild(br2);
}
}
function creaTextBox()
{
var t = document.createElement("input");
t.type = "text";
t.style.border = "1px black solid";
return t;
}
</script>
</head>
<body>
<form id="form1" action="">
<select id="Select1" multiple="multiple">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<hr />
<div id="div1"></div>
</form>
</body>
</html>