Web Analytics Made Easy -
StatCounter count up on load - CodingForum

Announcement

Collapse
No announcement yet.

count up on load

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • count up on load

    I am looking for a count up ... on load .. all what I have found works with a button start

    do you know one

    thank you

  • #2
    More details please.
    Glenn
    vBulletin Mods That Rock!

    Comment


    • #3
      I have found this script

      ------------------------------------------------

      <script language="JavaScript">
      var dt_deb = new Date();

      function pluriel(nb) {
      if (nb>1) {return "s"} else {return ""}
      }

      function FormatTemps(tps) {
      var reste="Temps = ";
      var min=Math.floor(tps/60);
      var sec=tps-min*60
      if (min>0) {reste+=min+" minute"+pluriel(min)+" "}
      if (sec>0) {reste+=sec+" seconde"+pluriel(sec)}
      return reste;
      }

      function CalculTemps() {
      var dt=new Date()
      tps = Math.round((dt.getTime() - dt_deb.getTime()) / 1000);
      document.getElementById("Clock")=FormatTemps(tps);
      setTimeout("CalculTemps()",1000);
      }
      CalculTemps()
      </script>


      <input type="text" id="Clock"/>
      -----------------------------------

      but I get an error

      I would like to have in he textBox

      hours minutes seconds >>>
      1 : 10 : 45

      thanks

      Comment


      • #4
        You called CalculTemps() that sets the value of the textbox before the textbox is rendered by the browser. The textbox must exist first before the function can be called. The solution is to call it onload.

        <body onload="CalculTemps()">
        <form>
        ...
        <input type="text" id="Clock"/>
        </form>
        </body>
        </html>
        Glenn
        vBulletin Mods That Rock!

        Comment


        • #5
          it works !!

          thanks a lot
          Last edited by castali; Mar 9, 2004, 06:34 AM.

          Comment

          Working...
          X