balkan7 Posted July 12, 2008 Share Posted July 12, 2008 i used php functions for datetime, php codes work perfectly but i add java script code for countdown minutes wait, doesnt work show nothing code java script is: <script language="JavaScript" type="text/javascript"> var theTime = document.getElementById('timer'); var sec = 01; // set the seconds var min = 10; // set the minutes function countDown() { sec--; if (sec == -01) { sec = 59; min = min - 1; } else { min = min; } if (sec<=9) { sec = "0" + sec; } time = (min<=9 ? "0" + min : min) + " min and " + sec + " sec "; if (document.getElementById) { theTime.innerHTML = time; } SD=window.setTimeout("countDown();", 1000); if (min == '00' && sec == '00') { sec = "00"; window.clearTimeout(SD); location.reload(true); } } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(function() { countDown(); }); </script> php code for check time is: <?php if ($now < $check_date){ echo "<div id='timer'></div>"; }?> also did id corect for refresh page after minutes and seconds are 00:00 -> location.reload(true) Link to comment https://forums.phpfreaks.com/topic/114434-countdown-doesnt-work-on-php/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.