Click to See Complete Forum and Search --> : Countdown Clock Problem


eitsfan
12-29-2003, 11:51 AM
Hello Everyone,

I was wondering if someone may be able to help me out? Here is my delima:

I have a script for a countdown clock I used to countdown to the Daytona 500, 2003. I just tried to reactivate it but the actual days, hours, minutes, etc... are not appearing on my website. All I did differently was to change the countdown-to date. Here is the script:

<table width="225" border="0" cellspacing="2" cellpadding="2">
<tr>
<td height="118" valign="top">
<table width="190" border="1" bordercolor="#000000">
<tr>
<td height="129">
<table width="190" border="0"
background="" height="116">
<tr>
<td colspan="3">
<table border="0" align="center">
<tr>
<td>
<script language="JavaScript1.2">

function setcountdown(theyear,themonth,theday,thehour,themin,thesec){
yr=theyear;mo=themonth;da=theday;hr=thehour;min=themin;sec=thesec
}

//////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////

//STEP 1: Configure the countdown-to date, in the format year, month, day, hour(0=midnight,23=11pm), minutes, seconds:
setcountdown(2004,02,15,13,00,00)

//STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
var occasion=""
var message_on_occasion="LET'S GO RACING!"

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area
var countdownwidth='125px'
var countdownheight='20px'
var countdownbgcolor='#FFFFFF'
var opentags='<b><font face="Verdana" color="black" size="2"><center>'
var closetags='</font></center></b>'

//////////DO NOT EDIT PAST THIS LINE//////////////////

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''

function start_countdown(){
if (document.layers)
document.countdownnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
countdown()
}

if (document.all||document.getElementById)
document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')

window.onload=start_countdown


function countdown(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
futurestring=montharray[mo-1]+" "+da+", "+yr+" "+hr+":"+min+":"+sec
dd=Date.parse(futurestring)-Date.parse(todaystring)
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
//if on day of occasion
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closeta gs)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+message_on_occasion+closetags
return
}
//if passed day of occasion
else if (dday<=-1){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+"Occasion already passed! "+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+"Occasion already passed! "+closetags
return
}
//else, if not yet
else{
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds"+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+dday+ " days "+dhour+" hours "+dmin+":"+dsec+" minutes"+closetags
}
setTimeout("countdown()",1000)
}
</script>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="25" width="66"><img src="04daytona500.gif" width="66" height="50" align="right"></td>
<td height="25" width="126">
<div align="center"><font color="red">Countdown to<br><b>DAYTONA!</B></font><br>
<hr>
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b>February 15, 2004<br>
<br>
</b></font> </div>
</div>
</td>
<td height="25" width="66"><img src="daytonalogo.gif" width="60" height="57" align="left"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>

</TD>
</TR>
</TABLE>

You can see the table in supposed action at this link:

http://eitsfan.tripod.com

PLMK if you can help me out! Thanks.
Chris

Pittimann
12-29-2003, 12:17 PM
Hi!

Your problem is quite small, but the code is quite long. In order to avoid posting such a code once more, I put it in the attachment.

There are just a few linebreaks in your code which result in your problem. Try the code from the attachment please.

Cheers - Pit

eitsfan
12-30-2003, 06:54 AM
Thanks Pit!

And I apologize for the long code in the post! Have a happy and safe New Year!

Chris:)

Pittimann
12-30-2003, 07:01 AM
Hi!

You're welcome! And - as far as I am concerned - no need to apologize for the long code. I just wanted to avoid it being posted a second time.

The best to you and everybody out there for the new year as well! ;)

Cheers - Pit