Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > JavaScript and CSS

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

JavaScript and CSS Extensible Markup Language, Java Script, and CSS questions here.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-29-2007, 12:45 AM
yogendra_kaushik yogendra_kaushik is offline
Newbie
 
Join Date: Nov 2007
Posts: 1
Credits: 0
Rep Power: 0
yogendra_kaushik is on a distinguished road
Default Help for making clock for time counter

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #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
Credits: 0
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-03-2008, 08:16 PM
alilg's Avatar   
alilg alilg is offline
Newbie
 
Join Date: Apr 2008
Location: Ultramarine
Age: 22
Posts: 16
Credits: 0
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

and i now i changed the above code to make a
digital clock with this format "00:00:00"

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>Digitl clock</title>
</head>
<body onload="timer()">

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

<script type="text/javascript">
var digiclock = "00:00:00";

i = 0;

function timer()
{
    var digiformat = "";
	if(i>3599)
	{
		var H = Math.floor(i/3600);
	}
	else
	{
		var H = 0;
	}
	
	var M = i - (H*3600)
	
	if(M>59)
	{
		M = Math.floor(M/60)
	}
	else
	{
		M = 0
	}	
	var S = i - (M*60)	
	if(H<10)
	{
		H = "0"+H;
	}
	if(M<10)
	{
		M = "0"+M;
	}
	if(S<10)
	{
		S = "0"+S;
	}
	
	document.getElementById('time').innerHTML = H+":"+M+":"+S;
    setTimeout('timer()', 1000);
    i++;
}

</script>

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


</body>
</html>
__________________
my free software and games
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript: Analog Clock TcM Javascript 20 05-28-2008 09:01 AM
WHAT is wrong with WHICH clock in my machine? tymoty General Programming 2 11-01-2007 10:59 PM
Creating an analog clock with ActionScript AfTriX Tutorials 2 01-07-2007 02:19 AM
Counter Blaze General Programming 1 08-22-2006 06:24 AM


All times are GMT -5. The time now is 07:40 PM.

Contest Stats

Xav ........ 1333.07
MeTh0Dz|Reb0rn ........ 1055.7
John ........ 881.37
morefood2001 ........ 879.43
marwex89 ........ 869.98
WingedPanther ........ 851.68
Brandon W ........ 757.44
chili5 ........ 312.39
Steve.L ........ 247.05
dcs ........ 219.87

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 82%

Ads