OhLordy
03-17-2004, 06:42 AM
Hi I'm getting a this.update is not a function error and I can't see anything wrong with it. It doesn't seem to mind the call in the constructor. Here's the code
<html>
<head></head>
<body onLoad="new Countdown('Sept 10 2004 00:00:01','img','')">
<script type="text/javascript">
//The Countdown Class
function Countdown(release,imgid,image)
{
//Attributes:
this.release = new Date(release)
this.imgid = imgid
var images = new Array()
for(var i=0;i<10;i++) {
images[i] = new Image()
images[i].src='./nems/'+image+i+'.gif'
}
this.images = images
this.update()
}
Countdown.prototype.update = function()
{
var now = new Date()
//Get the numerical values for the countdown parts
var seconds = Math.floor((this.release-now)/1000)
var minutes = Math.floor(seconds/60)
var hours = Math.floor(minutes/60)
var days = Math.floor(hours/24)
seconds = seconds-(minutes*60)
minutes = minutes-(hours*60)
hours = hours-(days*24)
//Calculate how the display looks
var img = new Array()
img[0] = this.images[Math.floor(seconds%10)]
img[1] = this.images[Math.floor(seconds%100)]
img[2] = this.images[Math.floor(minutes%10)]
img[3] = this.images[Math.floor(minutes%100)]
img[4] = this.images[Math.floor(hours%10)]
img[5] = this.images[Math.floor(hours%100)]
img[6] = this.images[Math.floor(days%10)]
img[7] = this.images[Math.floor(days%100)]
img[8] = this.images[Math.floor(days%1000)]
for(var i=0;i<9;i++) {
eval('document.images.'+this.imgid+i+'=img['+i+']');
}
window.setTimeout('this.update()',1000)
}
</script>
<div id="countdown"></div>
<?php
for($i=0;$i<9;$i++) {
echo('<img id="img'.($i+1).'" src="" alt=""/>'."\n");
}
?>
</body>
</html>
Thanks in advance
Bubble
<html>
<head></head>
<body onLoad="new Countdown('Sept 10 2004 00:00:01','img','')">
<script type="text/javascript">
//The Countdown Class
function Countdown(release,imgid,image)
{
//Attributes:
this.release = new Date(release)
this.imgid = imgid
var images = new Array()
for(var i=0;i<10;i++) {
images[i] = new Image()
images[i].src='./nems/'+image+i+'.gif'
}
this.images = images
this.update()
}
Countdown.prototype.update = function()
{
var now = new Date()
//Get the numerical values for the countdown parts
var seconds = Math.floor((this.release-now)/1000)
var minutes = Math.floor(seconds/60)
var hours = Math.floor(minutes/60)
var days = Math.floor(hours/24)
seconds = seconds-(minutes*60)
minutes = minutes-(hours*60)
hours = hours-(days*24)
//Calculate how the display looks
var img = new Array()
img[0] = this.images[Math.floor(seconds%10)]
img[1] = this.images[Math.floor(seconds%100)]
img[2] = this.images[Math.floor(minutes%10)]
img[3] = this.images[Math.floor(minutes%100)]
img[4] = this.images[Math.floor(hours%10)]
img[5] = this.images[Math.floor(hours%100)]
img[6] = this.images[Math.floor(days%10)]
img[7] = this.images[Math.floor(days%100)]
img[8] = this.images[Math.floor(days%1000)]
for(var i=0;i<9;i++) {
eval('document.images.'+this.imgid+i+'=img['+i+']');
}
window.setTimeout('this.update()',1000)
}
</script>
<div id="countdown"></div>
<?php
for($i=0;$i<9;$i++) {
echo('<img id="img'.($i+1).'" src="" alt=""/>'."\n");
}
?>
</body>
</html>
Thanks in advance
Bubble