Hi, could anyone tell me why I am unable to collect the value of a textbox created dynamically with the code below (source:[url]
Thank you in advance.
John
<HEAD>
<script type=”text/javascript”>
<!– var arrInput = new Array(0);
var arrInputValue = new Array(0);
function addInput() {
//arrInput.push(createInput(arrInput.length));
arrInput.push(arrInput.length);
//arrInputValue.push(arrInputValue.length);
arrInputValue.push(“”);
display();
}
function display() {
document.getElementById(‘parah’).innerHTML=””;
for (intI=0;intI<arrInput.length;intI++) {
document.getElementById(‘parah’).innerHTML+=createInput(arrInput[intI], arrInputValue[intI]);
}
document.testone.nooftb.value = intI;
}
function saveValue(intId,strValue) {
arrInputValue[intId]=strValue;
}
function createInput(id,value) {
return “<input type=’text’ id=’test “+ id +”‘ onChange=’javascript:saveValue(“+ id +”,this.value)’ value='”+ value +”‘><br>”;
}
// End –>
</script>
<%
processtb
%>
</HEAD>
<BODY>
<form name=testone id=testone action=’now.asp’ method=post>
<input type=hidden name=nooftb id=nooftb>
<p id=”parah”>Dynamic creation of input boxes</p>
<a href=”javascript:addInput()”>Add more input field(s)</a><br>
</form>
</body>
</html>
<%
sub processtb()
dim i, nooftb
dim tb()
nooftb = request(“nooftb”)
response.write nooftb
redim tb(nooftb)
if nooftb <> “” and nooftb > 0 then
for i = 0 to nooftb
tb(i) = request(“test ” & i)
response.write “tb” & i & ” ” & tb(i)
next
end if
end sub
%>