Countdown Script

Discussion in 'JavaScript' started by Munday, Oct 14, 2008.

  1. #1
    I want to create a page for one of my sites where it does a number countdown.

    I know there are loads of scripts for this but the type of countdown I want is quite bespoke.

    I want to show a counter of how much house prices are falling in the UK per day. For example, the average house price is dropping £100 per day and I want a live countdown which reflect the fall in real time.

    So for example the start of the countdown is £190,000.00, I want this to show the £100 coming off everyday but it for real time so it shows the decimal moving down as well (2 decimal places - UK pence).

    Does anyone know a good way to do this?

    Thanks in advance :)
     
    Munday, Oct 14, 2008 IP
  2. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Since you ask for the way, and not the exact script - take a look here. The script can be easily adjusted to count down from a number instead from a timestamp. Good luck :)
     
    xlcho, Oct 14, 2008 IP
  3. rhoula

    rhoula Well-Known Member

    Messages:
    875
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    145
    #3
    If you are still trying to get this script please send me more info i will do my best to help you.
    Thank you
     
    rhoula, Oct 20, 2008 IP
  4. webrickco

    webrickco Active Member

    Messages:
    268
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #4
    You need to take in consideration 2 different processing phases:
    - The user enter in your page and need to be informed of the value of the house at reference time (T) minus the decreased value for this house. For this you will need a function that updates the commercial value (£190000) at reference date (T) and calculates the value of the house now.

    Technically: You will need a function (decreaseTime for instance) to which you will pass 2 variables. The initial value (V) and the reference date (T format "y-m-d h:m:s"). The function should be to calculate the number of seconds between now and T and multiply this value by 100 / 24 / 3600 giving the instant value for the decrease (Vd). The function should return V - Vd.

    - You need a visual effect that will continuing decreasing the value while the user is viewing the page. You suggest a represention of the value with 2 decimals numbers. If we take in account a decrease of £100 every day, the value of the house will change about every 10 seconds, which is not very visual (100 / 24 / 60 /60 = 0,00115740... decreasing £0.01 in about 10 seconds). I would suggest to do like gmail main page does: putting more decimal cases. Like this, we will be able to have a visual result every second, or even less!

    Technically: you need a timer call to the first function every 1000ms or less. Each time decreaseTime is called, it will update the result with the current date/time.

    Need some more help: PM me!
     
    webrickco, Oct 24, 2008 IP