Hi Everyone,

I am a SharePoint Administrator, and have a bit of background knowledge with javascript, but not a huge amount so could use some help...

We have a 'Stocks and Commodities' webpart that updates the Oil and Gas price, as well as the share price on the intranet homepage. its in plain text and updates with a refresh. Basically what I want to do is have the rises and falls in the prices, '$change.text()' below, in green and red respectively...... but cannot figure out the code.

Below is want we currently have:

<div id="stockPrice"><p><strong>TSX: 11.25</strong> (-0.07)</p>
<p><strong>NYSE: 10.67</strong> (0.00)</p>
<p><strong>Brent Crude: 111.11</strong> (-0.55)</p>
<p><strong>Natural Gas: 3.707</strong> (+0.008)</p></div>
function handleResponse (json) {
for ( var i = 0; i < json.query.count; i++ ) {
var xml = xmlDoc = $.parseXML(json.results[i]), $xml = $( xmlDoc ), $symbol= $xml.find("Symbol"), $price = $xml.find("PreviousClose"), $change = $xml.find("Change");

var name = $symbol.text();

if($symbol.text() == "TLM.TO"){
name = "TSX";
} else if($symbol.text()=="TLM"){
name = "NYSE";
} else if($symbol.text()=="BZU13.NYM"){
name = "Brent Crude";
} else if($symbol.text()=="NGN13.NYM"){
name = "Natural Gas";

stockPrice.innerHTML += "<p><strong>"+ name + ": " + $price.text() + "</strong> ("+$change.text()+")</p>";

}</script><script src="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22TLM.TO%22%2C%22TLM%22%2C% 22BZU13.NYM%22%2C%22NGN13.NYM%22)%0A%09%09&amp;diagnostics=true&amp;env=http%3A%2F%2Fdatatables.org% 2Falltables.env&amp;callback=handleResponse"></script>

If anyone can point me in the right direction I would be very grateful.


Michael Clark