I have some javascript code that doesnt seem to be automatically updating on the page, any ideas? Have i setInterval correctly?
function updatePrice(id, currentPrice){
var newPrice = 0;
currentPrice = currentPrice * 100
if(rate == 1){
newPrice = currentPrice - 1;
}
if(rate == 2){
newPrice = currentPrice - 2;
}
if(rate == 3){
newPrice = currentPrice - 3;
}
document.getElementById(id).innerHTML = newPrice;
}
updatePrice('reverse', currentPrice);
var timeinterval = setInterval(updatePrice, 60000);
EDIT Thanks for everyones help, the only problem i have with passing arguments via updatePrice is that i want the price to decrease every minute, how would i set the argument to include the new price that has been calculated in the updatePrice function?
For example i think i would need something like: setInterval( function() { updatePrice('reserve',newPrice); }, 60000);
The newPrice being the price just calculated in updatePrice.
Hopefully this makes sense.
updatePricebut not passing any arguments...currentPriceseems to be a global and an argument name, the latter shadows the former.