...

View Full Version : Help with countdown clock in javascript!



roadrunnercompa
06-12-2004, 05:04 PM
i need help with this code. it countdown to a date, but i can't get it to a
special time ,, hours, minutes and second

the code is:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Ny sida 1</title>
<form name="count">
<input type="text" size="110" name="count2">
</form>
<script>
var before="TEXT"
var current="TEXT SOM SKALL KOMMA UPP NÄR TIDEN ÄR UTE"
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

function countdown(yr,m,d,h,min,s){
theyear=yr;themonth=m;theday=d;theshours=h;theminute=min;thesecond=s
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*60))%(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="Endast "+dday+ " dagar, "+dhour+" timmar, "+dmin+" minuter, och "+dsec+" sekunder kvar till "+before
setTimeout("countdown(theyear,themonth,theday)",1000)
}
countdown(2004,06,14,18,00,01)
</script>
</head>

<body>

</body>

</html>

Willy Duitt
06-12-2004, 05:36 PM
That looks like this script (http://www.javascriptkit.com/script/script2/count2.shtml) from Javascript Kit which you have tried to modify. Please edit your post and place the code into
...CODE HERE... tags and return the credits which you agreed not to remove when you got the script from Javascript Kit.


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


Also, you may wish to P/M a moderator and ask to have this thread moved to the Dynamic Drive Scripts Help (http://www.codingforums.com/forumdisplay.php?f=14) forum where it belongs.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum