Skip to main content

Javascript
Javascript
496 followers
19 questions
170 posts

Omkar Desai
print("Lifetime student")

SQL or Mongodb ?

Hello @Aniket Mahure if we send results that will be informed in telegram so stay updated with telegram and community.

<html>
<head>
<script>
var x;
var startstop = 0;

function startStop()
{

startstop = startstop + 1;

if (startstop === 1)
{
start();
document.getElementById("start").innerHTML = "Stop";
}
else if (startstop === 2)
{
document.getElementById("start").innerHTML = "Start";
startstop = 0;
stop();
}

}


function start()
{
x = setInterval(timer, 10);
}

function stop()
{
clearInterval(x);
}

var milisec = 0;
var sec = 0;
var min = 0;
var hour = 0;



var miliSecOut = 0;
var secOut = 0;
var minOut = 0;
var hourOut = 0;


function timer()
{
miliSecOut = checkTime(milisec);
secOut = checkTime(sec);
minOut = checkTime(min);
hourOut = checkTime(hour);

milisec = ++milisec;

if (milisec === 100)
{
milisec = 0;
sec = ++sec;
}

if (sec == 60)
{
min = ++min;
sec = 0;
}

if (min == 60)
{
min = 0;
hour = ++hour;

}


document.getElementById("milisec").innerHTML = miliSecOut;
document.getElementById("sec").innerHTML = secOut;
document.getElementById("min").innerHTML = minOut;
document.getElementById("hour").innerHTML = hourOut;

}



function checkTime(i)
{
if (i < 10)
{
i = "0" + i;
}
return i;
}

function reset()
{
milisec = 0;
sec = 0;
min = 0
hour = 0;

document.getElementById("milisec").innerHTML = "00";
document.getElementById("sec").innerHTML = "00";
document.getElementById("min").innerHTML = "00";
document.getElementById("hour").innerHTML = "00";

}

function timer1(){
var ip = document.getElementById(timer).value;
var tim = document.getElementById(time).value;
if(tim == "Seconds"){
alert("seconds");
}
else if(tim == "Minutes"){
alert("Minutes");
}
else{
alert("hours");
}
}
</script>
</head>
<body>
<center>
<h1>
<span id="hour">00</span> :
<span id="min">00</span> :
<span id="sec">00</span> :
<span id="milisec">00</span>
</h1>

<button onclick="startStop()" id="start">Start</button>
<button onclick="reset()">Reset</button>
<div>
<input type="number" id ="timer">
<select id="time">
<option value="Seconds">Seconds</option>
<option value="Minutes">Minutes</option>
<option value="Hours">Hours</option>
</select>
<input type="button" id="but1" onclick="timer1()" value="Start Timer">
</div>
</center>


</body>
</html>
JavaScript Cheatsheet
Source : https://websitesetup.org