hobbymaster001
09-08-2011, 08:43 PM
Hello, I have been working on a login system using scripts from around the net and my own custom ones. I have everything working perfectly but I wanted the news to display one way when they are logged in and one way when they log out. I modified a script that worked perfectly when I only had one element to modify, but when I changed things around to modify 2 divs it breaks.
The script works completely if I comment out one of the two "document.getElementById" lines at a time, but when they are both uncommented only the first of the two does anything. :mad:
This has been tested in FF, IE, Opera, Safari, and Chrome with the same results.
Am I really close, or is there something major I missed?
<script>
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
}
function displayResult()
{
xml=loadXMLDoc("includes/loginpanel/loginnews.xml");
xslli=loadXMLDoc("includes/loginpanel/loggedinnews.xsl");
xsllo=loadXMLDoc("includes/loginpanel/loggedoutnews.xsl");
// code for IE
if (window.ActiveXObject)
{
exli=xml.transformNode(xslli);
exlo=xml.transformNode(xsllo);
document.getElementById("loggedinnews").innerHTML=exlo;
document.getElementById("loggedoutnews").innerHTML=exlo;
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
lixsltProcessor=new XSLTProcessor();
loxsltProcessor=new XSLTProcessor();
lixsltProcessor.importStylesheet(xslli);
loxsltProcessor.importStylesheet(xsllo);
liresultDocument = lixsltProcessor.transformToFragment(xml,document);
loresultDocument = loxsltProcessor.transformToFragment(xml,document);
document.getElementById("loggedinnews").appendChild(liresultDocument);
document.getElementById("loggedoutnews").appendChild(loresultDocument);
}
}
</script>
The script works completely if I comment out one of the two "document.getElementById" lines at a time, but when they are both uncommented only the first of the two does anything. :mad:
This has been tested in FF, IE, Opera, Safari, and Chrome with the same results.
Am I really close, or is there something major I missed?
<script>
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
}
function displayResult()
{
xml=loadXMLDoc("includes/loginpanel/loginnews.xml");
xslli=loadXMLDoc("includes/loginpanel/loggedinnews.xsl");
xsllo=loadXMLDoc("includes/loginpanel/loggedoutnews.xsl");
// code for IE
if (window.ActiveXObject)
{
exli=xml.transformNode(xslli);
exlo=xml.transformNode(xsllo);
document.getElementById("loggedinnews").innerHTML=exlo;
document.getElementById("loggedoutnews").innerHTML=exlo;
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
lixsltProcessor=new XSLTProcessor();
loxsltProcessor=new XSLTProcessor();
lixsltProcessor.importStylesheet(xslli);
loxsltProcessor.importStylesheet(xsllo);
liresultDocument = lixsltProcessor.transformToFragment(xml,document);
loresultDocument = loxsltProcessor.transformToFragment(xml,document);
document.getElementById("loggedinnews").appendChild(liresultDocument);
document.getElementById("loggedoutnews").appendChild(loresultDocument);
}
}
</script>