View Single Post
  #2 (permalink)  
Old 04-03-2008, 07:54 PM
alilg's Avatar   
alilg alilg is offline
Newbie
 
Join Date: Apr 2008
Location: Ultramarine
Age: 22
Posts: 16
Rep Power: 2
alilg is on a distinguished road
Send a message via AIM to alilg Send a message via Yahoo to alilg Send a message via Skype™ to alilg
Default Re: Help for making clock for time counter

Quote:
Originally Posted by yogendra_kaushik View Post
Hello..alls
I am new in java script, I am making a application . in which i need to make a java script clock which count time ....I am trying to understand you it in more detail

After successfull user login clock show at top corner and it start from 00:00:00 and now it start time counting .

Can any one help he how can i do this
late reply i know, just for other people whom may have this question.

to make Countdown in javascript we need to work with Timers and setTimes.

this is a simple countdown script, watch it carefully to know how it works

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Countdown</title>
</head>
<body onload="timer()">

<style type="text/css">
#time{
font-size:50pt;
}
</style>

<script type="text/javascript">
i=90;
function timer()
{
    document.getElementById('time').innerHTML = i+1;
    setTimeout('timer()', 1000); //this will make loop this function for every one second
    i--;
}
</script>

<div id="time">90</div>


</body>
</html>
the 1000 says to timer which call the function every 1000 miliseconds which is equal to 1 second

if you to make the countdown FASTER, you can replace 1000 value with 500 for example.

to stop a javascript timer we will use ClearTIMER which i don't think you need it...
__________________
my free software and games
Reply With Quote