how to display timer dynamically in a asp.net form?
-
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?Thanx in advance
T.Balaji
-
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?Thanx in advance
T.Balaji
Use RegisterClientVariable
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Use RegisterClientVariable
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
At Server Side:
ClientScript.RegisterHiddenField("someHiddenField", "120");
At Client Side:
var someValue = document.getElementById("someHiddenField");
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.