Timer

Written by @ 5 October 2013

this is javascript code for timer...jst have to change to the form action

Code Snippet:

                                                
                                                <!-- this script is provided by https://www.javascriptfreecode.com coded by: Kerixa Inc. -->
<!-- saved from url=(0021)file:///I:/timer.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Countdown</title>
<script type="text/javascript">
// set minutes
var mins = 3;
 
// calculate the seconds (don't change this! unless time progresses at a different speed for you...)
var secs = mins * 60;
function countdown() {
	setTimeout('Decrement()',1000);
}
function Decrement() {
	if (document.getElementById) {
		minutes = document.getElementById("minutes");
		seconds = document.getElementById("seconds");
		// if less than a minute remaining
		if (seconds < 59) {
			seconds.value = secs;
		}
                else {
			minutes.value = getminutes();
			seconds.value = getseconds();
		}
                if(mins<2)
                    {
                        minutes.style.color="red";
                        seconds.style.color="red";
                    }
                 if(mins<0)
                 {
alert('time up');
document.forms["s"].submit();
//location.href = "index.jsp";
minutes.value=0;
seconds.value=0;
                 }
                 else
                     {
		secs--;
		setTimeout('Decrement()',1000);
                     }
            }
}
function getminutes() {
	// minutes is seconds divided by 60, rounded down
	mins = Math.floor(secs / 60);
       
	return mins;
}
function getseconds() {
	// take mins remaining (as seconds) away from total seconds remaining
	return secs-Math.round(mins *60);
}
</script>
</head>
<body onload="countdown();">
 
<div>
    Time left <input id="minutes" type="text" style="width: 10px; border: none; font-size: 16px; font-weight: bold; color: black;"><font size="5"> :</font><input id="seconds" type="text" style="width: 20px; border: none; font-size: 16px; font-weight: bold; color: black;"> 
</div>
    <form action="file:///I:/index.jsp" id="s">
        
    </form>

</body></html><a target='_blank' href='https://www.javascriptfreecode.com' style='font-size: 8pt; text-decoration: none'>JavaScript Best Codes</a>                                                
                                            

Example:


About @

This user is pending a biography.

Tags:
text

Comments


Here you can leave us commments. Let us know what you think about this code tutorial!

0 / 300

TRENDING POST
1
2
3
4
5
VISITORS
Online Users: 12
Recent Members: admin_js, bloxio, yqaice, flooketsu, phuang_test
advertisement 2