Добрый день, помогите разобраться, есть скрипт который должен заполнять форму таким образом: вводится имя, по нему ищется строка в базе и от туда берутся имена отца и матери, далее берется имя отца/матери и так же ищется строка.
таблица:
<table border=1>
<tr BGCOLOR=EEEEFF><td width=200 rowspan=8>
<INPUT TYPE=text SIZE=20 id=idf1 VALUE="" onChange="process(this.id)">
</td><td width=200 rowspan=4>
<INPUT TYPE=text SIZE=20 id=idf11 VALUE="" onChange="process(this.id)">
</td><td width=200 rowspan=2>
<INPUT TYPE=text SIZE=20 id=idf111 VALUE="" onChange="process(this.id)">
</td><td width=200>
<INPUT TYPE=text SIZE=20 id=idf1111 VALUE="" onChange="process(this.id)">
</td></tr>
<tr BGCOLOR=FFEEFF><td>
<INPUT TYPE=text SIZE=20 ID=idf1112 VALUE="" onChange="process(this.id)">
</td></tr><tr BGCOLOR=EEEEFF><td BGCOLOR=FFEEFF rowspan=2>
<INPUT TYPE=text SIZE=20 id=idf112 VALUE="" onChange="process(this.id)">
</td><td>
<INPUT TYPE=text SIZE=20 id=idf1121 VALUE="" onChange="process(this.id)">
</td></tr>
<tr BGCOLOR=EEEEFF><td BGCOLOR=FFEEFF>
<INPUT TYPE=text SIZE=20 id=idf1122 VALUE="" onChange="process(this.id)">
</td></tr><tr BGCOLOR=EEEEFF><td BGCOLOR=FFEEFF rowspan=4>
<INPUT TYPE=text SIZE=20 id=idf12 VALUE="" onChange="process(this.id)">
</td><td rowspan=2>
<INPUT TYPE=text SIZE=20 id=idf121 VALUE="" onChange="process(this.id)">
</td><td>
<INPUT TYPE=text SIZE=20 id=idf1211 VALUE="" onChange="process(this.id)">
</td></tr>
<tr BGCOLOR=EEEEFF><td BGCOLOR=FFEEFF>
<INPUT TYPE=text SIZE=20 id=idf1212 VALUE="" onChange="process(this.id)">
</td></tr><tr BGCOLOR=EEEEFF><td BGCOLOR=FFEEFF rowspan=2>
<INPUT TYPE=text SIZE=20 id=idf122 VALUE="" onChange="process(this.id)">
</td><td>
<INPUT TYPE=text SIZE=20 id=idf1221 VALUE="" onChange="process(this.id)">
</td></tr><tr BGCOLOR=EEEEFF><td BGCOLOR=FFEEFF>
<INPUT TYPE=text SIZE=20 id=idf1222 VALUE="" onChange="process(this.id)">
</td></tr>
</table>
и две функции:
idForm = "";
// make asynchronous HTTP request using the XMLHttpRequest object
function process(idForm0, idForm1)
{
idFormArray=new Array()
if (idForm1) idFormArray [0]=idForm0;
if (idForm2) idFormArray [1]=idForm1;
for (var i=0; i<idFormArray.length; i++){
document.getElementById("divProcess").innerHTML +=
'<i>' + idFormArray[i] + '</i><br>';
if (idFormArray[i].length>6){
break;}
else{
// proceed only if the xmlHttp object isn't busy
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
{
// retrieve the name typed by the user on the form
name = encodeURIComponent(document.getElementById(idFormArray[i]).value);
// execute the quickstart.php page from the server
xmlHttp.open("GET", "rss.php?name=" + name, true);
// define the method to handle server responses
idForm = idFormArray[i];
xmlHttp.onreadystatechange = handleServerResponse;
// make the server request
xmlHttp.send(null);
}
}
}
}
// executed automatically when a message is received from the server
function handleServerResponse()
{
// move forward only if the transaction has completed
if (xmlHttp.readyState == 4)
{
// status of 200 indicates the transaction completed successfully
if (xmlHttp.status == 200)
{
// extract the XML retrieved from the server
xmlResponse = xmlHttp.responseXML;
// obtain the document element (the root element) of the XML structure
xmlRoot = xmlResponse.documentElement;
idArray = xmlRoot.getElementsByTagName('id');
nameArray = xmlRoot.getElementsByTagName('name');
otecArray = xmlRoot.getElementsByTagName('otec');
matArray = xmlRoot.getElementsByTagName('mat');
// get the text message, which is in the first child of
// the the document element
var d = document;
idFormOtec = idForm + "1";
idFormMat = idForm + "2";
for (var i=0; i<idArray.length; i++){
document.getElementById("div2").innerHTML +=
'<i>' + idFormOtec + '</i><br>';
if (idFormOtec.length>7){
break;}
else{
d.getElementById(idForm).value = nameArray.item(i).firstChild.data;
d.getElementById(idFormOtec).value = otecArray.item(i).firstChild.data;
d.getElementById(idFormMat).value = matArray.item(i).firstChild.data;
//alert (idFormOtec);
}}
// restart sequence
setTimeout('process(idFormOtec, idFormMat)', 10);
}
// a HTTP status different than 200 signals an error
else
{
alert("There was a problem accessing the server: " + xmlHttp.statusText);
}
}
}
Таблица на половину заполняется, вся отцовская линия idf1-idf1111, а вот все что идет начиная от idf12 пустое. Если в первую функцию вставить alert(idFormArray[i]), то idf121 и idf122 заполняются, но дальше пусто. Xто-то с циклами не так, но где именно понять не могу.
PS xml формируется правильно.