如何得到动态创建的控件的值
<html>
<head>
</head>
<body>
<table width=100%>
<tr>
<td width=50%>
</td>
<td width=50% >
<form name=key >
<DIV id=text> </DIV>
<input type=button value= '确定 ' onClick= 'javascript:query(); '>
</form>
</td>
</tr>
</table>
</body>
<script language= "javascript ">
var list = new Array(108);
for (int i = 0; i < 108; i++)
list[i] = "-1 ";
var fso = new ActiveXObject( "Scripting.FileSystemObject ");
alert( "ok ");
var fData = fso.OpenTextFile( "E:\\office\\doc\\other\\td.txt ", 1);
var sel = " <input type= 'radio ' name= 'selid ' value= '1 '/> ";
var strText = " ";
var i = 0;
while (true) {
strText += " <p> " + fData.readline() + " </p> ";
strText += " <input type= 'radio ' name= 'selid " + i + " ' value= '1 ' checked /> 明显不符 ";
strText += " <input type= 'radio ' name= 'selid " + i + " ' value= '2 ' /> 大多不符 ";
strText += " <input type= 'radio ' name= 'selid " + i + " ' value= '3 ' /> 难以决定 ";
strText += " <input type= 'radio ' name= 'selid " + i + " ' value= '4 ' /> 大体相符 ";
strText += " <input type= 'radio ' name= 'selid " + i + " ' value= '5 ' /> 非常符合 ";
i++;
if (i == 108)
break;
}
fData.close();
document.getElementById( "text ").innerHTML = strText;
function query() {
var els = document.getElementsByTagName( "input ");
for(var i = 0, i < 108; i++) {
alert(els[i].value);
}
}
</script>
</html>
大家帮忙看看,具体功能就是读文件得到要创建的控件名,单击按钮,输出所有控件的值
------解决方案--------------------首先,你的需求并不十分明显.
1,你的第二行,有语法错误,是for(var i = 0;不是for(int i = 0;
2,最后一个循环处,改为for(var i = 0; i < 108;
然后,你是想取得所有以selid开头的的INPUT对象的值吧?
var els = document.getElementsByTagN