04-04-2009, 08:58 PM
|
#9 (permalink)
|
|
The Contributor
Join Date: Feb 2009
Posts: 65
Thanks: 0
|
I thought I should give you some code that has some performance improvement.
You may want to ignore this till you get the above working.
In my previous code for some dumb reason I made the function work like a loop. I am not sure why I did that as a loop would run faster.
So the following code uses a for loop and in so doing condenses the code more.
Also each loop does takes a fraction of time to run. So I have made the code reduce the timer by a fraction of a second for each additional row that must be looped through.
HTML Code:
<script type="text/javascript">
var rowcount = 4;
function multiCountDown(){
var endcount = true;
for (var nextrow = 1; nextrow <= rowcount; nextrow++) {
if (document.getElementById('mycount'+nextrow).innerHTML != 0) {
document.getElementById('mycount'+nextrow).innerHTML = document.getElementById('mycount'+nextrow).innerHTML - 1;
endcount = false;
}
}
if(!endcount) {
var sectimer = Math.round(1000 - (rowcount / 2 ));
counter = setTimeout("multiCountDown();", sectimer);
}
else {
clearTimeout(counter);
}
}
</script>
|
|
|
|