Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear All

kindly i have a qustion

i have a code to read an xml file to make new ticker tape and i want to check element if more than zero, change the color in ticker

please help me if you can


and the code is

XML
<DIV ID="TICKER" STYLE="overflow:hidden" onmouseover="TICKER_PAUSED=true" onmouseout="TICKER_PAUSED=false" class="aligncenter"/>
<script language="javascript">
var ajxObj;
if (window.XMLHttpRequest) {
ajxObj = new XMLHttpRequest();
} else {
ajxObj = new ActiveXObject('Microsoft.XMLHTTP');
}
ajxObj.open('GET', 'OutputXML.xml', false);
ajxObj.send();

var myXml = ajxObj.responseXML;
prs = myXml.getElementsByTagName("Table4")
for (i = 0; i < prs.length ; i++) {
document.write(prs[i].getElementsByTagName('ticker')[0].childNodes[0].nodeValue);
document.write('>>');
document.write(prs[i].getElementsByTagName('comp_current_price')[0].childNodes[0].nodeValue);
document.write(' % ');
document.write(prs[i].getElementsByTagName('change_perc')[0].childNodes[0].nodeValue);
document.write('..........');
}
</script>
</div>
Posted

1 solution

I have hardcoded the colors you can use class.

XML
<DIV>

<script language="javascript">
var ajxObj;
if (window.XMLHttpRequest) {
ajxObj = new XMLHttpRequest();
} else {
ajxObj = new ActiveXObject('Microsoft.XMLHTTP');
}
ajxObj.open('GET', 'OutputXML.xml', false);
ajxObj.send();

var myXml = ajxObj.responseXML;
prs = myXml.getElementsByTagName("Table4")

if(prs.length >0 )
{
document.write('<DIV ID="TICKER" STYLE="overflow:hidden" onmouseover="TICKER_PAUSED=true" onmouseout="TICKER_PAUSED=false" class="aligncenter" style="background-color:#003366;" />');
}
else document.write('<DIV ID="TICKER" STYLE="overflow:hidden" onmouseover="TICKER_PAUSED=true" onmouseout="TICKER_PAUSED=false" class="aligncenter" style="background-color:#000366;" />');

for (i = 0; i < prs.length ; i++) {
document.write(prs[i].getElementsByTagName('ticker')[0].childNodes[0].nodeValue);
document.write('>>');
document.write(prs[i].getElementsByTagName('comp_current_price')[0].childNodes[0].nodeValue);
document.write(' % ');
document.write(prs[i].getElementsByTagName('change_perc')[0].childNodes[0].nodeValue);
document.write('..........');
}
document.write('</div>');
</script>

</div>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900