topical media & game development
#javascript-generator-count-down.htm / htm
<!-- THREE STEPS TO INSTALL DATE COUNTDOWN:
1. Paste the first into the HEAD of your HTML document
2. Code the OnLoad event handler into the BODY tag
3. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Copy this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var Temp2;
var timerID = null;
var timerRunning = false;
function arry() {
this.length = 12;
this[0] = 31;
this[1] = 28;
this[2] = 31;
this[3] = 30;
this[4] = 31;
this[5] = 30;
this[6] = 31;
this[7] = 31;
this[8] = 30;
this[9] = 31;
this[10] = 30;
this[11] = 31;
}
var date = new arry();
function stopclock() {
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock() {
stopclock();
showtime();
}
function showtime() {
now = new Date();
var CurMonth = now.getMonth();
var CurDate = now.getDate();
var CurYear = now.getFullYear();
now = null;
if (1 < CurDate) {
CurDate -= date[CurMonth]; CurMonth++;
}
if (0 < CurMonth) {
CurMonth -= 12; CurYear++;
}
var Yearleft = 1999 - CurYear;
var Monthleft = 0 - CurMonth;
var Dateleft = 1 - CurDate;
document.dateform.a.value = Yearleft;
document.dateform.b.value = Monthleft;
document.dateform.c.value = Dateleft;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Add the OnLoad event handler to the BODY tag -->
<BODY Onload="startclock()">
<!-- STEP THREE: Insert this code into the BODY of your HTML document -->
<form name=dateform>Only
<input type=text name=a size=2 value=""> years,
<input type=text name=b size=2 value=""> months, and
<input type=text name=c size=2 value=""> days left until 1/1/1999</form>
<!-- Script Size: 1.95 KB -->
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.