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.

Have A Look At Some Of Our Webmaster Related Sponsors!


Script Directory


Advertise Here


Market Leverage


Free Templates

3D Guide-Characters
3D Guide-characters


Advertise Here

Reply
 
LinkBack Thread Tools Display Modes
Old 06-05-2008, 03:52 AM   #1 (permalink)
New Hunter
 

Join Date: Jun 2008
Posts: 1
iTrader: 0 / 0%
Hunter Bux: 0
kaushal is on a distinguished road
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
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.
__________________
+-(X)HTML, CSS, JavaScript, SEO, PHP, Flash-+
Code:
<style type="text/css"> u { text-decoration: none; } </style>
GameYin. Redesigning for DevPlooth.
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
iTrader: 0 / 0%
Hunter Bux: 0
snapple is on a distinguished road
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
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 08:50 AM.


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