Hi
I’ve got a little bit of ajax happening that gets a mails “read” status from a mysql database. I’m then exporting an xml file of the data to read back in with javascript.
This bit all seems to be fine. The problem i’m having is with the imported xml data i need to hide or unhide a div
i’ve got divs on the page that look like
<div id=’readMail39′ style=’display:none’>
the javascript code i’ve got is
[code]
var mId = xmlDoc.getElementsByTagName(“email”) //<< MAIL ID AND STATUS
var numMails = xmlDoc.getElementsByTagName(’email’).length //NUMBER OF EMAILS
var mNum;
for (i=0;i<numMails;i++)
{
mNum = mId[1].childNodes[0].nodeValue;
if (mId[i].childNodes[1].lastChild.nodeValue == 0)
{
document.getElementById(‘readMail’+mNum).style.display = ‘none’;
document.getElementById(‘unreadMail’+mNum).style.display = ‘block’;
}
else
{
document.getElementById(‘readMail’+mNum).style.display = ‘block’;
document.getElementById(‘unreadMail’+mNum).style.display = ‘none’;
}
}
i think it’s the “mNum” variable that keeps messing things up as i keep getting the error:
Error: document.getElementById(“readMail” + mNum) has no properties
if i try and cheat it however by just changing to display =’block’ line to
document.getElementById(‘readMail39’).style.display = ‘block’;
it works fine. what am i getting so wrong????
my xml is
[code]
<mail>
<email>
40
<status>1</status>
</email>
<email>
38
<status>0</status>
</email>
<email>
39
<status>0</status>
</email>
<email>
41
<status>1</status>
</email>
</mail>
any ideas on this would be amazing
Thank you