Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If the User Start to Fill the Form the Time Starts from 00:00:01 to continuously... Its been Clearly performed By using Javascript:

HTML
<script language="JavaScript" type="text/javascript">

JavaScript
var c = 0;
var m = 0;
var h = 0;
var t;
var timer_is_on = 0;

function timedCount()
{
    document.getElementById('lblsec').innerHTML = c;
    document.getElementById('lblmins').innerHTML = m + ' : ';
    document.getElementById('lblhrs').innerHTML = h + ' : ';
    c = c + 1;

    if(c > 59)
    {
        m = m + 1;
        c = 0;
        if(m > 59)
        {
            h = h + 1;
            m = 0;
        }
    }
    t = setTimeout("timedCount()", 1000);

}

function doTimer()
{
    if (!timer_is_on)
    {
        timer_is_on = 1;
        timedCount();
    }
}

window.onload = doTimer;

HTML
</script>


This Script is Clearly Working....
My Big Issue is..

I have Three LinkButtons , if i Click any Link Button the Whole Page is Reloading and also the time is reset and starts from 00:00:01...

Can anyone help me..

Regards,
Prince Antony G
Posted
Updated 11-Nov-11 19:12pm
v2
Comments
[no name] 12-Nov-11 0:48am    
FORMAT you your code snippets when posting!!!
Prince Antony G 12-Nov-11 1:01am    
how to format

1 solution

The timer is resetting because the link buttons cause a postback which causes the page to reload and the script to start again. The web is stateless, to the browser every time a page is loaded it is treated as the first time unless handled otherwise.
 
Share this answer
 
Comments
Prince Antony G 12-Nov-11 0:54am    
Thanks for ur reply...
then what is the solution for this issue?...
[no name] 12-Nov-11 2:03am    
the solution is to not cause a postback or when you do to pass back to the script the time the count should begin from.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900