MuphN Posted January 31, 2014 Share Posted January 31, 2014 Hello. I need help with my js, basicly its js count down that counts to zero, I think it should be correct, umm I dont really understand the part where it says if (M > 30) { - I understand that if minutes is higher then 30 mins, y = sets a, but I need to make it that if minutes reaches 00:00 add php script <?php $uploadToDB ?> and restarts the countdown. How can I do that? Hares the script of js countdown. <HTML> <HEAD> <TITLE>Count Down Timer</TITLE> <script> //add leading zeros setInterval(function() { function addZero(i) { if (i < 10) { i = "0" + i; } return i; } var x = document.getElementById("timer"); var d = new Date(); var s = (d.getSeconds()); var m = (d.getMinutes()); var a = addZero(60 - 60); var b = addZero(60 - m); var c = (60 - s); if (m > 30) { y = a; } if (m == 0) { return true; } var t = y + (":" + addZero(c)); x.innerHTML = t; }, 250); </script> </HEAD> <BODY> <div align="center" id="timer" style='color:black;font-size:24px;' ></div> </BODY> </HTML> Quote Link to comment https://forums.phpfreaks.com/topic/285841-adding-a-php-function-to-js/ Share on other sites More sharing options...
.josh Posted February 2, 2014 Share Posted February 2, 2014 javascript cannot directly call a php function. You need to use ajax to make a request to a php script that will execute the function. Read up on ajax. Quote Link to comment https://forums.phpfreaks.com/topic/285841-adding-a-php-function-to-js/#findComment-1467424 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.