Countdown html

  • 1
  • Question
  • Updated 10 years ago
  • Answered
Hello everyone,

I am having trouble getting this code to work. Every time I try to post it it says there is an error with the javascript code and all it produces is a white box. Here is the code:

<!--<form name="count">
<input type="text" size="80" name="count2">
</form>

<script>

/*
Count down until any date script-
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free scripts here!
*/

//change the text below to reflect your own,
var before="Auction is over!"
var current="The Auction is over!"
var montharray=new

Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov

","Dec")

function countdown(yr,m,d){
theyear=yr;themonth=m;theday=d
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[m-1]+" "+d+", "+yr
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(dday==0&&dhour==0&&dmin==0&&dsec==1){
document.forms.count.count2.value=current
return
}
else
document.forms.count.count2.value="Only "+dday+ " days, "+dhour+"

hours, "+dmin+" minutes, and "+dsec+" seconds left until "+before
setTimeout("countdown(theyear,themonth,theday)",1000)
}
//enter the count down date using the format year/month/day
countdown(2009,06,1)
</script>
-->
Photo of lambofgod

lambofgod

  • 875 Posts
  • 35 Reply Likes

Posted 10 years ago

  • 1
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Hi lambofgod

You're right.. the code doesn't work. I went back to the original, copied it and pasted it and it worked right away for me.

Perhaps you might have copied it wrong or accidentally delete a part of the code. Go back to the source again and try. This is the one I tried: http://www.javascriptkit.com/script/s...
Photo of lambofgod

lambofgod

  • 875 Posts
  • 35 Reply Likes
Yeah I went back and tried it but this time I copied and pasted directly from jsk. It worked. But when I save it as a txt file on notepad and the copy/paste it, it doesn't work. Weird eh?
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
That is weird. Oh well.. at least you got it working now! =)
Photo of lambofgod

lambofgod

  • 875 Posts
  • 35 Reply Likes
Exactly! Thanks for you help and input. Kinda slow tonight here at GS isn't it?
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
A little slow - some days it's even slower! And other days, it's hopping mad!