woodchip
01-01-2004, 11:14 PM
The following counter was working fine until year 2004 clicked over;
http://www.forestrytasmania.com/not_working.html
now it doesn't work properly.
It should only be showing around 15,000 per day starting 1 Jan 04 (instead of 3 million plus) and the images on the RH side do not work.
Can anyone assist to modify the script to work in 2004?
olerag
01-02-2004, 03:02 PM
I altered your "init()" function and tested for dates from
Dec/2003 thru Jan/2005. To fix, the "parseInt()" function
was used for all of your addition calcs.
I believe this will get you what you expect and, maybe,
will also fix your image problem as well.
<html>
<head>
<script type="text/javascript">
function init() {
var temp="";
var test = new Array();
test[0] = new Date(2003,11,1);
test[1] = new Date(2004,0,1);
test[2] = new Date(2004,1,1);
test[3] = new Date(2004,2,1);
test[4] = new Date(2004,3,1);
test[5] = new Date(2004,4,1);
test[6] = new Date(2004,5,1);
test[7] = new Date(2004,6,1);
test[8] = new Date(2004,7,1);
test[9] = new Date(2004,8,1);
test[10] = new Date(2004,9,1);
test[11] = new Date(2004,10,1);
test[12] = new Date(2004,11,1);
test[13] = new Date(2005,0,1);
for (var i=0; i<test.length; i++) {
hh = test[i].getHours();
mm = test[i].getMinutes();
ss = test[i].getSeconds();
yy = test[i].getYear();
mt = test[i].getMonth() + 1;
dd = test[i].getDate();
if (mt == 2) {
countdown = 467015000;}
else if (mt == 3) {
countdown = 888835000;}
else if (mt == 4){
countdown = 1355850000;}
else if (mt == 5){
countdown = 1807800000;}
else if (mt == 6){
countdown = 2274815000;}
else if (mt == 7){
countdown = 2726765000;}
else if (mt == 8){
countdown = 3193780000;}
else if (mt == 9){
countdown = 3660795000;}
else if (mt == 10){
countdown = 4112745000;}
else if (mt == 11){
countdown = 4579760000;}
else if (mt == 12){
countdown = 5031710000;}
else {
countdown = 0;
}
dds = parseInt(dd * 15065000);
countdown += parseInt(dds);
dds = parseInt(mm * 10500);
countdown += parseInt(dds);
dds = parseInt(ss * 175);
countdown += parseInt(dds);
nmtext = countdown.toString();
temp += mt + "/" + (1900 + yy) + ": " + nmtext + "\n";
}
alert("Estimates for Fiscal Year: 2004:\n" + temp);
}
</script>
</head>
<body>
<center>
<b>Title</b>
<form>
<input type="button" value="Execute" onClick="init()">
</form>
<hr>
</center>
</body>
</html>