Prova cosi (è meglio usare getElementById che non all )
codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
var ind=0;
function createInput(toObjId) {
var anObj = document.getElementById(toObjId);
anObj.innerHTML += '<input type="text" size="20" maxlength="20" id="autoIn['+ind+']">
';
ind++;
} // function createInput(toObjId)
function seeInput() {
cont = true;
idx = 0
while (cont) {
curId = 'autoIn['+idx+']';
curObj = document.getElementById(curId);
if (curObj != null) {
alert(curObj.value);
} else {
cont = false;
} // if (curObj != null)
idx++;
} // while (cont)
} // function seeInput()
//-->
</script>
</head>
<body>
<div id="container">
</div>
<input type="button" value="Crea" onclick="createInput('container')">
<input type="button" value="Values" onclick="seeInput()">
</body>
</html>
</body>
</html>
Oppure
codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
var ind=0;
function createInput(toObjId) {
var anObj = document.getElementById(toObjId);
anObj.innerHTML += '<input type="text" size="20" maxlength="20" id="autoIn'+ind+'">
';
ind++;
} // function createInput(toObjId)
function seeInput() {
var oColl = document.getElementsByTagName('INPUT');
for (i = 0; i < oColl.length; i++) {
curObj = oColl.item(i);
if (curObj.type == 'text' && curObj.id.substr(0,6) == 'autoIn') {
alert(curObj.value);
} // if (curObj.type == 'text' && curObj.id.substr(0,6) == 'autoIn')
} // for (i = 0; i < oColl.length; i++)
} // function seeInput()
//-->
</script>
</head>
<body>
<div id="container">
</div>
<input type="button" value="Crea" onclick="createInput('container')">
<input type="button" value="Values" onclick="seeInput()">
</body>
</html>