Hello i am making a stopwatch but i dont have any idea how to make a laptime for my stopwatch
js code
function init() {`
var stopwatch1 = new Timer("timerLabel1", "start1");
document.getElementById("start1").onclick = function(){
stopwatch1.start();
}
document.getElementById("reset1").onclick = function(){
stopwatch1.reset();
}
var stopwatch2 = new Timer("timerLabel2", "start2");
document.getElementById("start2").onclick = function(){
stopwatch2.start();
}
document.getElementById("reset2").onclick = function(){
stopwatch2.reset();
}
var stopwatch3 = new Timer("timerLabel3", "start3");
document.getElementById("start3").onclick = function(){
stopwatch3.start();
}
document.getElementById("reset3").onclick = function(){
stopwatch3.reset();
}
document.getElementById("moveAllBtn").onclick = function(){
if (document.getElementById("moveAllBtn").value == 'START') {
stopwatch1.status = 0;
stopwatch2.status = 0;
stopwatch3.status = 0;
} else {
stopwatch1.status = 1;
stopwatch2.status = 1;
stopwatch3.status = 1;
}
stopwatch1.start();
stopwatch2.start();
stopwatch3.start();
}
}
function Timer(timerLabelId, startBtnId) {
this.status = 0;
this.time = 0;
this.timerLabel = document.getElementById(timerLabelId);
this.startBtn = document.getElementById(startBtnId);
}
Timer.prototype.start = function() {
if (this.status == 0) {
this.status = 1;
this.startBtn.value = "STOP";
this.count();
} else {
this.status = 0;
this.startBtn.value = "START";
}
}
Timer.prototype.count = function() {
if (this.status == 1) {
var that = this;
setTimeout(function(){
that.time++;
that.timerLabel.innerHTML = getTime(that.time);
that.count();
}, 10);
document.getElementById("moveAllBtn").value = 'STOP';
} else {
document.getElementById("moveAllBtn").value = 'START';
}
}
Timer.prototype.reset = function() {
this.status = 0;
this.time = 0;
this.startBtn.value = "START";
this.timerLabel.innerHTML = "00:00.00";
}
function getTime(time) {
var min = Math.floor(time/100/60);
var sec = Math.floor(time/100);
var mSec = time%100;
if (min < 10) {
min = "0" + min;
}
if (sec >= 60) {
sec = sec % 60;
}
if (sec < 10) {
sec = "0" + sec;
}
return min + ":" + sec + "." + mSec;
}
init();
}`
i want to post this time on screen and send it to my mysql database any tips ?