VB icon

Stopwatch

Email
Submitted on: 4/24/2019 6:28:48 PM
By: Divyank Sharma 
Level: Beginner
User Rating: Unrated
Compatibility: HTML 5, CSS, JavaScript
Views: 239
 
     It is simple basic stopwatch code where simple coding is done in javascript using javascript function and called on onclick event and for styling basic css is used.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Stopwatch
' Description:It is simple basic stopwatch code where simple coding is done in javascript using javascript function and called on onclick event and for styling basic css is used.
' By: Divyank Sharma
'**************************************

<html>
<head>
<style>
div.dd{max-height:4vw; min-height:3vw; max-width:30vw; border:5px double black; word-spacing:0px; background-color:lightgrey; border-radius:10px;}
th#a3{border:2px solid black; font-size:33px; height:10%; width:5vw; border-radius:10px;}
th#a1{font-size:2vw;}
div#a4{ margin:30px;}
div#d1,#d2,#d3{background-color:grey; width:5vw; font-size:2vw; height:10%; border-radius:10px;}
</style>
<script>
var slot1 = 0;
var slot2 = 0;
var slot3 = 0;
function first()
{
	slot1++;
	document.getElementById("d1").innerHTML = slot1;
	setTimeout('first()',10);
	if(slot1==60)
	{
		slot1=0;
	}
}
function second()
{
	slot2++;
	document.getElementById("d2").innerHTML = slot2;
	setTimeout('second()',100);
	if(slot2==60)
	{
		slot2=0;
	}
	
}
function third()
{
	slot3++;
	document.getElementById("d3").innerHTML = slot3;
	setTimeout('third()',1000);
}
function restart()
{
	slot1=-1;
	slot2=-1;
	slot3=-1;
}
</script>
</head>
<body onload="first(),second(),third()">
<center><div class="dd">
<table>
<tr>
<th id="a3"><div id="d1">0</div></th><th id="a1">:</th>
<th id="a3"><div id="d2">0</div></th><th id="a1">:</th>
<th id="a3"><div id="d3">0</div></th>
<div id="d4"></div>
</tr>
<table>
</div>
<div id="a4"><input type="button" value="restart" onclick="restart()"></div>
</center>
</body>
</html>


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.