Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-12-2004, 04:04 PM   PM User | #1
roadrunnercompa
New to the CF scene

 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
roadrunnercompa is an unknown quantity at this point
Help with countdown clock in javascript!

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>
roadrunnercompa is offline   Reply With Quote
Old 06-12-2004, 04:36 PM   PM User | #2
Willy Duitt
Banned

 
Join Date: Sep 2003
Posts: 3,620
Thanks: 0
Thanked 0 Times in 0 Posts
Willy Duitt is an unknown quantity at this point
That looks like this script from Javascript Kit which you have tried to modify. Please edit your post and place the code into [code]...CODE HERE...[/code] tags and return the credits which you agreed not to remove when you got the script from Javascript Kit.

Quote:
/*
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 forum where it belongs.
Willy Duitt is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:51 AM.


Advertisement
Log in to turn off these ads.