Friday, May 22, 2009

Javascript Timer Control

//Just Paste the following code in between the script tag

<script type="text/javascript" language="javascript"/>
var hour=11;

var minutes=59;

var seconds=59;

function timedCount()

{

//Textbox name is txt and time would be started in the textbox

document.getElementById('txt').value=hour+":"+minutes+":"+seconds;

if(hour==11 && minutes==58 && seconds==59)

{

//as soon as the time reach 11:58:59 it will transfer itself to another page Default.aspx

window.location.href='Default.aspx';

}

else if(seconds==0)

{

minutes-=1;

seconds=60;

}

if(minutes==01)

{

hour-=1;

minutes=59;

seconds=60;

}

seconds-=1;

//timedcount function decrase by one second which is mentioned here in Millisecond

t=setTimeout("timedCount()",1000);

}

</script>

No comments:

Post a Comment