c_shelswell Posted May 22, 2007 Share Posted May 22, 2007 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 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 <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 Quote Link to comment Share on other sites More sharing options...
c_shelswell Posted May 22, 2007 Author Share Posted May 22, 2007 SOLVED!! This took a while - i just needed to parse it as an integer mNum = mId.childNodes[0].nodeValue; pointValue_n = parseInt(mNum,10); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.