The code below works just fine. It replaces the innerHTML of a single span tag named "countDown".
I've tried to edit the code so it adds the countdown numbers to multiple places (span's) on the page but I can't get anything to work. I tried using 'getElementsByClassName' but I cant figure out what the code should be to use a class instead of an id. I'm assuming that would be the best way or I could use multiple id names like: "countDown1", "countDown2", etc.
Can someone please tell me what I should change?
The span's that need to show the countdown are not under the same parent div.
Code:<script type="text/javascript"> <!-- window.onload = function() { startCountDown(120, 1000, myFunction); } function startCountDown(i, p, f) { // store parameters var pause = p; var fn = f; // make reference to div var countDownObj = document.getElementById("countDown"); if (countDownObj == null) { // error alert("div not found, check your id"); // bail return; } countDownObj.count = function(i) { // write out count countDownObj.innerHTML = i; if (i == 0) { // execute function fn(); // stop return; } setTimeout(function() { // repeat countDownObj.count(i - 1); }, pause ); } // set it going countDownObj.count(i); } function myFunction() { window.setTimeout('window.location="<?php echo $redLink; ?>"; ',2000); } --> </script>


Reply With Quote

Bookmarks