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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.