#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    67
    Rep Power
    14

    JavaScript-Countdown via perl script?


    Hi,

    i do have no knowledge about javascript - based on this i need some help for the following:

    Let's say i have a perl routine with a saved time splitted into the variables $days, $hours, $mins ...

    Now i want to display on the html-output of the perl-script anywhere a live countdown like:

    Countdown:
    -------------------------------
    |days|hours|minutes|seconds|
    -------------------------------

    Would be great if anyone could create me a short snippet how i could insert anything like this ...

    Thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2001
    Location
    Toronto, Ontario, Canada
    Posts
    631
    Rep Power
    14
    From your perl/cgi script, you should write the whole document.

    print <<END_OF_PAGE;
    <html><head>...</head><body>
    ........ all the content.....
    $day , $hour , etc.
    ...
    </body></html>

    END_OF_PAGE

    Using this (being a perl/cgi newbie -- started to learn today, lol) I dont know if the time could be updated, unless you use javascript. I'm not sure if defining the javascript variables with the perl variables will work though, but you can give it a try.

    print <<END_OF_PAGE;
    <html><head><script language="javascript">
    var secs=$seconds
    function updateSec() {
    secs++;
    document.write(secs);
    SecsTimeout=setTimeout("updateSec()",1000)
    }
    updateSec()
    </script><body>..</body></html>
    END_OF_PAGE

IMN logo majestic logo threadwatch logo seochat tools logo