I have a progress bar, and I have my js getting the value of it with document.getElementsByTagName(progressbar)[num]
. I have this in multiple functions, but when one of the progress bars are removed, the others don't continue because num
is set... How do I fix this?
function plantTree()
{
if(water > 10){
var doSome = doSom;
doSom++;
water -= 10;
var div = document.getElementById("plantATree");
div.innerHTML = "<progress val='0' max='100'></progress>";
var i = 0;
var inte = setInterval(function(){
document.getElementsByTagName("progress")[doSome].value += 5;
i++;
if(i >= 20){
window.clearInterval(inte);
}
},1000);
var inter = setInterval(function(){
var progVal = document.getElementsByTagName("progress")[doSome].value;
if (progVal >= 100){
statusTwoUpdate("You have finished Planting a Tree...", "wood += 5");
window.clearInterval(inter);
div.innerHTML = "Plant a Tree";
doSom--;
}
},500);
}else{
statusTwoUpdate("You tried and failed...", "water -= 6");
}
}
EDIT: Here is a like to all the javascript I use: http://hastebin.com/gucuwaxema.coffee