Click here to Skip to main content
14,330,512 members
Rate this:
Please Sign up or sign in to vote.
See more:
Timer stop button using to stop timer.

What I have tried:

timer javascript
<script>
					function divhide()
						{
							document.getElementById('rndbox').style.display="block";
							$("#beg").slideUp("6000");
						
						}
					function starttimer(seconds)
						{
							document.getElementById('showquesbox').style.display="block";
							$("#rndbox").slideUp("6000"); 
							countDown('my_div1', '<div>TIME OVER</div>',seconds); 
							document.getElementById('starttest').disabled="disabled";
							document.getElementById('starttest').style.display = "none";
						
						}
					function countDown(elID, output, seconds)
						{
							var elem = document.getElementById(elID),
							start = new Date().getTime(), end = start+seconds*1000,
							timer = setInterval(function() {
							
							var now = new Date().getTime(), timeleft = end-now, timeparts;
							
							if( timeleft < 0) {
							document.getElementById('submit').submit();
							elem.innerHTML = output;
							showanswer();
							document.getElementById('nextprev').style.display = "none";
							document.getElementById('endtest').style.display="block";
							$('input[type=radio]').attr('disabled', 'disabled'); 
							document.getElementsByTagName('input').type.radio.disabled="disabled";
							
							clearInterval(timer);
						}
							else 
								{
									timeparts = [Math.floor(timeleft/60000),Math.floor(timeleft/1000)%60];
									if( timeparts[1] < 10) timeparts[1] = "0"+timeparts[1];
									elem.innerHTML = "Time left: "+timeparts[0]+":"+timeparts[1];
								}

							} ,250); // the lower this number, the more accurate the timer. 250 recommended 
}</script>

html code of timer-
<ul style="border:0px #000000 solid;margin: 0px;padding: 0;">
			<div id="leveldiv">
			
					<div style="text-align:center;float:right">
						<input type="button" name="starttest" value="START TEST" class="start" id="starttest" onclick="starttimer('20')">
					</div>
					
				</div>
		
		<div id="showquesbox" class="showquesbox_classs" style="display: none;">
		<div id="my_div1" align="right"></div>
Posted
Comments
ZurdoDev 7-Oct-19 14:51pm
   
Where are you stuck?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100