04-04-2009, 07:06 PM
|
#8 (permalink)
|
|
The Contributor
Join Date: Feb 2009
Posts: 65
Thanks: 0
|
Ok this is a case of needing to walk through a couple things
First merge the two <script> sections
HTML Code:
<script type="text/javascript">
var rowcount = <?php echo $rowcount; ?>;
var nextrow = 1;
var endcount = true;
function multiCountDown(){
if (nextrow >= rowcount) {
if (document.getElementById('mycount'+nextrow).innerHTML != 0) {
document.getElementById('mycount'+nextrow).innerHTML = document.getElementById('mycount'+nextrow).innerHTML - 1;
endcount = false;
}
nextrow--;
multiCountDown();
}
else {
if(!endcount) {
nextrow = 1;
endcount = true;
counter = setTimeout("multiCountDown();", 1000);
}
else {
clearTimeout(counter);
}
}
}
</script>
Next, understanding DOM is a part of what is going on here. "getElementById" is exactly that "get element by id" and "innerHTML" is exactly that as well. So "getElementById('mycount1').innerHTML" is "get element id of mycount1's inner HTML". And if you look at your page that elements innerHTML is ''. So '' - 1 = ''. So it is working.
Also if your start "nextrow" at 1 having an element of "mycount0" means the javascript will never look at it. So either start your row naming at 1 or make "nextrow" 0.
|
|
|
|