Jump to content

Adding a php function to js.


MuphN

Recommended Posts

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>
Link to comment
https://forums.phpfreaks.com/topic/285841-adding-a-php-function-to-js/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.