Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Javascript

Javascript

Scheduled Pinned Locked Moved ASP.NET
javascriptsysadmin
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    senthilsstil
    wrote on last edited by
    #1

    Hi Friends, I m decresing the time using javascript user defined function startTimer1(), I am calling that function in body load event Its working fine but user clicks server button the time is decreasing very fast. My logic is right.i dont know where I call that function. This is my coding function startTimer1(h,m,s) { if(document.getElementById('txt').innerHTML=="00:00:00") { alert("Your time is Over,Now the Application is going to close"); //self.close(); window.close(); return false; } var today=new Date(); if(h=="0" && m=="0" && s=="0") { h=00; m=01; s=00; } else { if(s=="00") { s=59; if(m=="00" && h!="00") { h=parseInt(h)-1; m=59; } else if(m!="00" && h=="00") { m=parseInt(m)-1; } else if(m!="00" && h!="00") { m=parseInt(m)-1; } else if(s=="00" && m=="00") { if(h!="00") h=parseInt(h)-1; } } else s=parseInt(s)-1; } // add a zero in front of numbers<10 h=checkTime(h); m=checkTime(m); s=checkTime(s); document.getElementById('txt').innerHTML=h+":"+m+":"+s; t=setTimeout('startTimer1('+h+','+m+','+s+')',1000); } function checkTime(i) { if (i<10) { i="0" + i; } return i; }

    E 1 Reply Last reply
    0
    • S senthilsstil

      Hi Friends, I m decresing the time using javascript user defined function startTimer1(), I am calling that function in body load event Its working fine but user clicks server button the time is decreasing very fast. My logic is right.i dont know where I call that function. This is my coding function startTimer1(h,m,s) { if(document.getElementById('txt').innerHTML=="00:00:00") { alert("Your time is Over,Now the Application is going to close"); //self.close(); window.close(); return false; } var today=new Date(); if(h=="0" && m=="0" && s=="0") { h=00; m=01; s=00; } else { if(s=="00") { s=59; if(m=="00" && h!="00") { h=parseInt(h)-1; m=59; } else if(m!="00" && h=="00") { m=parseInt(m)-1; } else if(m!="00" && h!="00") { m=parseInt(m)-1; } else if(s=="00" && m=="00") { if(h!="00") h=parseInt(h)-1; } } else s=parseInt(s)-1; } // add a zero in front of numbers<10 h=checkTime(h); m=checkTime(m); s=checkTime(s); document.getElementById('txt').innerHTML=h+":"+m+":"+s; t=setTimeout('startTimer1('+h+','+m+','+s+')',1000); } function checkTime(i) { if (i<10) { i="0" + i; } return i; }

      E Offline
      E Offline
      eyeseetee
      wrote on last edited by
      #2

      so you mean this code is on page_load, but if a user click a button and it posts back to the server then the timer countdown increases in speed? Please explain your problem a bit more cheers!

      S 1 Reply Last reply
      0
      • E eyeseetee

        so you mean this code is on page_load, but if a user click a button and it posts back to the server then the timer countdown increases in speed? Please explain your problem a bit more cheers!

        S Offline
        S Offline
        senthilsstil
        wrote on last edited by
        #3

        Not page_load(), the problem is while clicking server control its getting postback and body onload event is calling.So time is decreasing fastly.

        E 1 Reply Last reply
        0
        • S senthilsstil

          Not page_load(), the problem is while clicking server control its getting postback and body onload event is calling.So time is decreasing fastly.

          E Offline
          E Offline
          eyeseetee
          wrote on last edited by
          #4

          you need to put the timer on a page init, if its onload then every time page loads or re-loads it will affect the timer

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups