Go Back   DevHunters.com l Webmaster Forum - Web Advertising - Web Design - SEO Forums > Webmaster / Coding / Web Design Discussion > JavaScript Programming

JavaScript Programming Discuss javascript coding.

Reply
 
LinkBack Thread Tools Display Modes
Old 06-05-2008, 03:52 AM   #1 (permalink)
New Hunter
 
Join Date: Jun 2008
Posts: 1
HB$ Balance: 0
kaushal is on a distinguished road
iTrader: (0)
Default Count up counter in javascript

Hi All,

I have to built a counter (count will start from 1 and will increment to 1 every second) which will start or paused on click of button. Can anybody give some idea on how to proceed for this.

Regards,
Kaushal
kaushal is offline   Reply With Quote
Old 06-05-2008, 06:59 AM   #2 (permalink)
Senior Moderator
 
SpOrTsDuDe.Reese's Avatar
 
Join Date: Jan 2008
Location: Whiteford, MD
Posts: 1,152
HB$ Balance: 586.00
SpOrTsDuDe.Reese has a spectacular aura aboutSpOrTsDuDe.Reese has a spectacular aura aboutSpOrTsDuDe.Reese has a spectacular aura about
iTrader: (1)
Send a message via AIM to SpOrTsDuDe.Reese
Default

Hmm, would you like us to use our knowledge of us reading your mind? How are we supposed to know without code o.O. A website would be preferable.
__________________
Looking for HTML/CSS work. If interested in hiring, please Use my site

/* CSS guru */
SpOrTsDuDe.Reese is offline   Reply With Quote
Old 07-14-2008, 10:41 AM   #3 (permalink)
New Hunter
 
snapple's Avatar
 
Join Date: Jul 2008
Location: Texas
Posts: 1
HB$ Balance: 0
snapple is on a distinguished road
iTrader: (0)
Default Javascript Up-Counter

Quote:
Originally Posted by kaushal View Post
Hi All,

I have to built a counter (count will start from 1 and will increment to 1 every second) which will start or paused on click of button. Can anybody give some idea on how to proceed for this.

Regards,
Kaushal
Here is one I use. It is not mine, but works perfect. Enjoy.

Code:
<html>
<head>
<title>CountUp Script</title>
<script type="text/javascript">
function showElapsedTime()
{
// Description:
// This is a countup script from a specific date in the past.
// It shows the days, hours, minutes and seconds that have elapsed since the start date.
// For added effect, the elapsed time is updated each second.
//
// Set the starting date details.
var startYear = 2007;
var startMonth = 11; // must be between 0 - 11
var startDay = 21; // must be between 1 - 31
var startHour = 0; // must be between 0 - 23
var startMinute = 0; // must be between 0 - 59
var startSecond = 0; // must be between 0 - 59
var startDate = new Date();
startDate.setYear(startYear);
startDate.setMonth(startMonth);
startDate.setDate(startDay);
startDate.setHours(startHour);
startDate.setMinutes(startMinute);
startDate.setSeconds(startSecond);
var rightNow = new Date();
var elapsedTime = rightNow.getTime() - startDate.getTime();
var one_day=1000*60*60*24;
var elapsedDays = Math.floor( elapsedTime / one_day );
var milliSecondsRemaining = elapsedTime % one_day;
var one_hour = 1000*60*60;
var elapsedHours = Math.floor(milliSecondsRemaining / one_hour );
milliSecondsRemaining = milliSecondsRemaining % one_hour;
var one_minute = 1000*60;
var elapsedMinutes = Math.floor(milliSecondsRemaining / one_minute );
milliSecondsRemaining = milliSecondsRemaining % one_minute;
var one_second = 1000;
var elapsedSeconds = Math.round(milliSecondsRemaining / one_second);
document.getElementById('elapsedTime').innerHTML = elapsedDays + " Days " + elapsedHours + " Hours " + elapsedMinutes + " Minutes " + elapsedSeconds + " Seconds";
t = setTimeout('showElapsedTime()',1000);
}
</script>
</head>
<body onload="showElapsedTime()">
<div id="elapsedTime"></div>
</body>
</html>
snapple is offline   Reply With Quote
Old 12-09-2008, 11:08 PM   #4 (permalink)
New Hunter
 
Join Date: Dec 2008
Posts: 3
HB$ Balance: 0
Thomas00 is on a distinguished road
iTrader: (0)
Default search-and-destroy

To protect your computer, it is vital that you use a powerful antivirus and antispyware scanner like www.search-and-destroy. Free update antivirus definitions daily, scan your computer once a day for infections and keep all of your software patched and up-to-date.
Thomas00 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
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

Forum Jump


All times are GMT -5. The time now is 04:01 PM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios