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
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. java script timer control

java script timer control

Scheduled Pinned Locked Moved .NET (Core and Framework)
javajavascripttoolsquestion
3 Posts 3 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.
  • B Offline
    B Offline
    balaji t
    wrote on last edited by
    #1

    hi folks, I wud like to display running time in my page using javascript.For that i ve used the following client side function. <form name="counter"><input type="text" size="8" name="d2"></form> <script type="text/javascript"> var milisec=0 var seconds=120 // document.counter.d2.value=0 function display() { if (milisec<=0){ milisec=9 seconds-=1 } if (seconds<=-1) { milisec=0 seconds+=1 } else milisec-=1 document.counter.d2.value=seconds+"."+milisec setTimeout("display()",1000) } display() ive hardcoded it as 120 seconds.But i need to pass a value from code behind dynamically and make the timer run for that value. for e.g i want to pass as display(180) and run the timer.Is there any way of achieving this?Advance thanx

    T.Balaji

    B J 2 Replies Last reply
    0
    • B balaji t

      hi folks, I wud like to display running time in my page using javascript.For that i ve used the following client side function. <form name="counter"><input type="text" size="8" name="d2"></form> <script type="text/javascript"> var milisec=0 var seconds=120 // document.counter.d2.value=0 function display() { if (milisec<=0){ milisec=9 seconds-=1 } if (seconds<=-1) { milisec=0 seconds+=1 } else milisec-=1 document.counter.d2.value=seconds+"."+milisec setTimeout("display()",1000) } display() ive hardcoded it as 120 seconds.But i need to pass a value from code behind dynamically and make the timer run for that value. for e.g i want to pass as display(180) and run the timer.Is there any way of achieving this?Advance thanx

      T.Balaji

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      It'll be better if you ask the same question in ASP.NET section then it'll be easier for all and you'll get answer early :)

      Cheers!! Brij

      1 Reply Last reply
      0
      • B balaji t

        hi folks, I wud like to display running time in my page using javascript.For that i ve used the following client side function. <form name="counter"><input type="text" size="8" name="d2"></form> <script type="text/javascript"> var milisec=0 var seconds=120 // document.counter.d2.value=0 function display() { if (milisec<=0){ milisec=9 seconds-=1 } if (seconds<=-1) { milisec=0 seconds+=1 } else milisec-=1 document.counter.d2.value=seconds+"."+milisec setTimeout("display()",1000) } display() ive hardcoded it as 120 seconds.But i need to pass a value from code behind dynamically and make the timer run for that value. for e.g i want to pass as display(180) and run the timer.Is there any way of achieving this?Advance thanx

        T.Balaji

        J Offline
        J Offline
        John Ad
        wrote on last edited by
        #3

        Hi Balaji, Use RegisterClientVariable, you may refer to the following code snippet: At Server Side: ClientScript.RegisterHiddenField("HiddenField", "120"); At Client Side: var temp = document.getElementById("HiddenField"); I hope this would be helpful.

        John Adams ComponentOne LLC. www.componentone.com

        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