Vote count: 0
I want to do after I clicked a button to start countdown and when the timer reaches 0 to execute a query to the database. I do timer JS (I do not know how much is correct, but it works), I am interested after reaching the end how to execute an SQL query? And also, I need at refresh the page timer continues to count down rather than start from scratch ..
This is what i make:
var elapsed= "20";
function calcTimeLeft(numSec) {
if (numSec <= 0) {
window.location=window.location;
}
console.log(elapsed);
var sec = numSec%60;
var min = parseInt(numSec/60);
if(min>60){
var h = parseInt(min/60);
min = min-h*60;
}else{
h=0;
}
min = (min<10?"0":"")+min;
sec = (sec<10?"0":"")+sec
document.getElementById("timer").innerHTML = "Остава: "+h+" часа "+min+" минути "+sec+" секунди";
setTimeout("calcTimeLeft("+(numSec-1)+");", 1000);
}
onLoad=calcTimeLeft(elapsed);
asked 25 secs ago
Javascript timer refresh and php function
Aucun commentaire:
Enregistrer un commentaire