utahman3431
06-10-2008, 10:49 PM
I am using javascript to display a menu that is pulled from an xml document and sorted alphabetically using xslt. I want to be able to click on a link and display the data on a different <div> on the webpage. The script I have to display the information is:
function show(i)
{
title=(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
body=(x[i].getElementsByTagName("body")[0].childNodes[0].nodeValue);
txt= "<center><h2>" + title + "</h2></center><br />" + body;
document.getElementById("mainbdy").innerHTML=txt;
document.getElementById("subnav").style.visibility='hidden';
return false;
}
the only problem is when I click on a link from my sorted list that isn't originally in the XML document alphabetically, it displays the information in that location of the XML page. I was hoping I could just use a different item other than "i" to choose which part of the XML document to display. Each item has a unique <name> tag. Is it possible to get the information using some variable associated to <name> rather than "i"?
function show(i)
{
title=(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
body=(x[i].getElementsByTagName("body")[0].childNodes[0].nodeValue);
txt= "<center><h2>" + title + "</h2></center><br />" + body;
document.getElementById("mainbdy").innerHTML=txt;
document.getElementById("subnav").style.visibility='hidden';
return false;
}
the only problem is when I click on a link from my sorted list that isn't originally in the XML document alphabetically, it displays the information in that location of the XML page. I was hoping I could just use a different item other than "i" to choose which part of the XML document to display. Each item has a unique <name> tag. Is it possible to get the information using some variable associated to <name> rather than "i"?