I have a method in my java code that is calculating the current price, i then use this in my javascript code shown below.
function updatePrice(id, currentPrice){
var newPrice = 0;
var cPrice = currentPrice;
cPrice = cPrice * 100;
if(rate == 1){
newPrice = cPrice - 1;
}
if(rate == 2){
newPrice = cPrice - 2;
}
if(rate == 3){
newPrice = cPrice - 3;
}
document.getElementById(id).innerHTML = newPrice/100;;
return newPrice / 100;
}
var nPrice = updatePrice('reverse', currentPrice); //The new calculated price, currentPrice is the price first injected into the script
var timeinterval = setInterval(function() { nPrice = updatePrice('reverse', nPrice); }, 60000); //the nPrice as currentPrice
I want to be able to use the newPrice calculated in updatePrice on itself when running setInterval, so that once a minute the newPrice is being used to go down by 1, 2 or 3(pence);
Its probably something quite simple that i just havent noticed yet.
Hopefully this makes sense, fill free to request more info if needed.