mootools - Javascript Need to pull a value from a function within an array -
here code:
<script> window.addevent('domready', function(){ new request.stocks({ stocks: ['sxcl'], oncomplete: function(yahoo){ var result = ''; array.each(array.from(yahoo.query.results.quote), function(quote){ result += '<div class="company-ticks"></div> <span class="company">steel excel ({name})</span> <span class="sub-info"> - otc markets<span> </div> <div><span class="value"> {lasttradepriceonly}</span><span class="changeup"> <img src="change-up.gif" class="change-img" />{change} ({changeinpercent})</span></div></div>'.substitute(quote); }, this); $('stocks').set('html', result); }, onrequest: function(script){ $('stocks').set('text', 'loading...'); } }).send(); // request.stocks.element.js }); </script>
you see have variable {change]. need determine if variable positive or negative value. if positive should display class "changeup" , image change-up.gif. if value negative class displayed should "changedown" , image change-down.gif
the images green arrow , red arrow down. classes make color altrenate between red , green.
because within array thats being called using function i'm not sure how go this. assume have split "result" 3 sections. section before, section sets class , image, , rest of result.
any appreciated.
this uses javascript mootools. it's pulling stock quote yahoo.