views:

40

answers:

1

I have searched long and hard for module that would show Customer Savings(in $$). There are two ways I wish to possibly implement this.


Method One:
Customer enters a "base" $$ amount, start date, and an incrementing value per time period
Ex: Base=$1,000,000; Start:1/1/2010; Increment=$100; Time Period=Minute
This would diplay $1,432,000 after exactly 3 days (3days*24hrs*60mins*$100=$432,000 since 1/1/2010)
Each time the person refreshed the page, the amount saved would be calculated based on the difference in time between the start date and current date, and displayed to the user.

Method Two:(IDEAL)
Same setup as above, but savings would be updated every second (and possibly with some kind of odometer-looking counter that is constantly rolling over).

Has anyone seen or heard of any module like this? I have searched high and low and the only "counters" I can find are hit counters and such. If no one is aware of any pre-existing modules, how could this be coded into a DotNetNuke module? I have not yet delved into the world of coding custom modules. I have only tweaked other modules to make them work the way I need.
Any and all help is greatly appreciated!
UPDATE:
Here is my final code. In the "footer" section (under Settings) of DNN HTML module: $(document).ready(function(){

setTimeout('countit()',1); //1 makes it display the value quickly after loading    
});

function countit()
{
  var amountperyear=4000000; //THIS IS THE ONLY NUMBER TO EDIT EACH YEAR

  var msperyear=31536000000; //milliseconds per year

  var today=new Date();
  var startdate=new Date(today.getYear(),0,00);  //January 1, of the current year at midnight?
  var diff=Math.ceil((today.getTime()-startdate.getTime())); //Time difference in milliseconds
  var newvalue=(diff*(amountperyear/msperyear)); // (# of ms) * (amount/ms)
  var displayvalue=newvalue.toLocaleString(); //Convert to currency formatting
  $("#mycounter").html("$"+displayvalue);
  setTimeout('countit()',500); //Have it update twice per second
}

</script>

In the Content section of the DNN HTML module:

<center>
This year, we've saved our customers:
<b><div id="mycounter"><i>Loading...</i></div></b>
</center>