firepages
12-22-2002, 02:05 PM
Hi, I am trying to iterate through an array and dynamically alter the contents of some <span></span>'s
to avoid doing this for each element..
C_TITLE.innerText=xmlDoc.getElementsByTagName("C_TITLE").item(current).text
that fills in the <span id="C_TITLE"></span> which works fine
I am currently trying this...
var bits=new Array('C_TITLE','C_NAME','C_SURNAME','C_EXPIRY','C_ENTITY','C_ADDRESS1','C_ADDRESS2','C_SUBURB','C_P OSTCODE','C_PHONE','C_PHONE2','C_MOBILE','C_FAX','C_EMAIL','C_WEBSITE','C_OCCUPATION');
for (var i in bits){
bits[i].innerText=xmlDoc.getElementsByTagName(bits[i]).item(current).text
}
which does not, I have tried eval()'ing the statment etc but to no avail, I am sure its just a syntax issue with the
bits[i].innerText bit but cant find the right way to do this (the getElementsByTagName(bits[i]) does not itself seem to be an issue)
please enlighten !
to avoid doing this for each element..
C_TITLE.innerText=xmlDoc.getElementsByTagName("C_TITLE").item(current).text
that fills in the <span id="C_TITLE"></span> which works fine
I am currently trying this...
var bits=new Array('C_TITLE','C_NAME','C_SURNAME','C_EXPIRY','C_ENTITY','C_ADDRESS1','C_ADDRESS2','C_SUBURB','C_P OSTCODE','C_PHONE','C_PHONE2','C_MOBILE','C_FAX','C_EMAIL','C_WEBSITE','C_OCCUPATION');
for (var i in bits){
bits[i].innerText=xmlDoc.getElementsByTagName(bits[i]).item(current).text
}
which does not, I have tried eval()'ing the statment etc but to no avail, I am sure its just a syntax issue with the
bits[i].innerText bit but cant find the right way to do this (the getElementsByTagName(bits[i]) does not itself seem to be an issue)
please enlighten !