Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

countdown using getTimer()? 1

Status
Not open for further replies.

martinb7

Programmer
Jan 5, 2003
235
0
0
GB
Hi, i was wondering how to make a dynamic textbox called timeleft countdown from a set time to 0 and when it reaches 0 do something.

I know it involves the getTimer() but not quite sure how to use it

Help!!

Thanx

Martin
 
just change the value of seconds to your number and have a textbox with instance name theTime

seconds = 1000;

function formatTime(time) {
var h = Math.floor(time/3600)<10 ? &quot;0&quot;+Math.floor(time/3600) :
Math.floor(time/3600);
var m = (Math.floor((time/60)%60)<10) ? &quot;0&quot;+Math.floor((time/60)%60) :
Math.floor((time/60)%60);
var s = ((time%60)<10) ? &quot;0&quot;+(time%60) : (time%60);
return h+&quot;:&quot;+m+&quot;:&quot;+s;
}

function clock() {
seconds --;
theTime.text = formatTime(seconds);
if(seconds==0){
//do somthing
clearInterval(theTimer)
}
}
theTimer = setInterval(clock, 1000);
 
i cant seem to get it to work:(

can u make me a .fla in a .zip for me?

Thanx

Martin
 
Yes he did, didn't he? How about a star for the man?

frozenpeas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top