Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Count up Script from XXX, 6 per minute - Newbie needs your help :)
Old 06-18-2007, 10:31 AM Count up Script from XXX, 6 per minute - Newbie needs your help :)
Novice Talker

Posts: 11
Trades: 0
I'm looking for a script that will count up from a given number and XX ammounts per minute. My english sucks, but I hope you can understand what I mean:

I like to have a sentence on my website like this: "We have printed 18.059.123 Business Cards."

The above number should be based on this: 16.500.000 is the start value, then per year I want added 3,15 million. That equals around 6 per minute.

Is there any hero out there able to build me this in PHP? This would save my ***...

Thanks for any help!
iternity is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-18-2007, 10:46 AM Re: Count up Script from XXX, 6 per minute - Newbie needs your help :)
akratellio's Avatar
Experienced Talker

Posts: 30
Location: Berlin Germany Europe World
Trades: 0
Hi,

if you want to have this in php you will need a refresh every minute.
put your 16.500.000 in a form element an then add 6 while the page is refreshing.

I guess it would be much better to watch out for a js script

greetings akratellio
__________________
I'm always lying...
Ich lüge immer...

Please login or register to view this content. Registration is FREE
akratellio is offline
Reply With Quote
View Public Profile Visit akratellio's homepage!
 
Old 06-18-2007, 10:47 AM Re: Count up Script from XXX, 6 per minute - Newbie needs your help :)
Novice Talker

Posts: 11
Trades: 0
oh well... I have no clue how to do this... but thank you for your reply!
iternity is offline
Reply With Quote
View Public Profile
 
Old 06-18-2007, 04:34 PM Re: Count up Script from XXX, 6 per minute - Newbie needs your help :)
Novice Talker

Posts: 11
Trades: 0
Anyone out there with help for me?
iternity is offline
Reply With Quote
View Public Profile
 
Old 06-18-2007, 07:57 PM Re: Count up Script from XXX, 6 per minute - Newbie needs your help :)
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
Add this between your html <head> tags:
Code:
<script language="javascript" type="text/javascript">
<!--
  
  var startCount = 16500000;
  var addPerMin = 6;
  
  function ProcessCounter() {
    document.getElementById('cnt').innerHTML = addCommas(String(cnt++));
    setTimeout('ProcessCounter()', SetTimeOutPeriod);
  }
  
  function PutSpan() {
    document.write('<span id="cnt"></span>');
  }
  
  function addCommas(nStr) {
   var rgx = /(\d+)(\d{3})/;
   while (rgx.test(nStr)) {
    nStr = nStr.replace(rgx, '$1' + ',' + '$2');
   }
   return nStr;
  }
  
  var cnt = startCount;
  var SetTimeOutPeriod = Math.floor((1000 * 60) / addPerMin);
  function displayCounter() {
    PutSpan();
    ProcessCounter();
  }
  
//-->
</script>
And add this where you want the number to display:
Code:
<script language="javascript" type="text/javascript">javascript:displayCounter();</script>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-19-2007, 07:00 AM Re: Count up Script from XXX, 6 per minute - Newbie needs your help :)
Novice Talker

Posts: 11
Trades: 0
Wow!!! Thank you very much for your great help! Is there a way to have it saved (or compared with another number to get the same effect)?
Right now it starts fresh (at 16.5 mil.) on every page load but it should "remember" the already counted number.

So the script should show something like 18.05 mil. already (start value = 16.5 mil. + 3.1 mill / year [= 6 per second]) for this half new year added.

Again, thank you VERY much for your kind help!

Last edited by iternity; 06-19-2007 at 04:20 PM..
iternity is offline
Reply With Quote
View Public Profile
 
Old 06-19-2007, 09:42 PM Re: Count up Script from XXX, 6 per minute - Newbie needs your help :)
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
You can do it with php:

PHP Code:
<?php
  
  $add_per_minute 
6;
  
$starting_count_number   16500000;
  
$starting_count_datetime '06/19/2007 19:30:00';
  
?>
<script language="javascript" type="text/javascript">
<!--
  function ProcessCounter() {
    document.getElementById('cnt').innerHTML = addCommas(String(cnt++));
    setTimeout('ProcessCounter()', SetTimeOutPeriod);
  }
  function PutSpan() {
    document.write('<span id="cnt"></span>');
  }
  function addCommas(nStr) {
   var rgx = /(\d+)(\d{3})/;
   while (rgx.test(nStr)) {
    nStr = nStr.replace(rgx, '$1' + ',' + '$2');
   }
   return nStr;
  }
  var cnt = <?php echo $starting_count_number floor(((time() - strtotime($starting_count_datetime)) / 60) * $add_per_minute); ?>;
  var SetTimeOutPeriod = Math.floor((1000 * 60) / <?php echo $add_per_minute?>);
  function displayCounter() {
    PutSpan();
    ProcessCounter();
  }
//-->
</script>

We have printed <script language="javascript" type="text/javascript">javascript:displayCounter();</script> &nbsp;Business cards.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-20-2007, 07:04 PM Re: Count up Script from XXX, 6 per minute - Newbie needs your help :)
Novice Talker

Posts: 11
Trades: 0
Hi,
and thank you!

Isn't it possible to do all this purely in JS? I can not run PHP withting the site I use. But thank you very much man!
iternity is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Count up Script from XXX, 6 per minute - Newbie needs your help :)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31901 seconds with 12 queries