PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Dec 15, 2017 5:12 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Time counter issue
PostPosted: Thu Dec 29, 2011 9:36 am 
Offline
Forum Newbie

Joined: Tue Aug 16, 2011 10:13 am
Posts: 24
I have added a time counter in below code. This is used to track the total time of a project. If a person is going on break, then they will apply the break that stops the time counter. However, once they come back from break and end the break, then time is counting at double speed (two seconds instead at one second). Any help.........



Syntax: [ Download ] [ Hide ]
<html>
<head>
   
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <title>Strategy One - Tracker</title>

    <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
    <!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]-->


       
        <!-- Script for Current time in text box -->
<script type="text/javascript">
function GetDate()
{
        var curDateTime = new Date()
        var curHour = curDateTime.getHours()
        var curMin = curDateTime.getMinutes()
        if(curHour<10) curHour = "0" + curHour
        if(curMin<10) curMin = "0" + curMin
       
 
        document.getElementById('start_time').value = curHour + ":" + curMin;
        var row = document.getElementById("end1_time");
        var row1 = document.getElementById("start1_time");
        row.style.display = 'none';
                 row1.style.display = 'none';

}
</script>
<!-- End of Script for Current time in text box -->
<!-- Script for Current time in text box -->
<script type="text/javascript">
function GetDate1()
{
        var curDateTime = new Date()
        var curHour = curDateTime.getHours()
        var curMin = curDateTime.getMinutes()
        if(curHour<10) curHour = "0" + curHour
        if(curMin<10) curMin = "0" + curMin
        document.getElementById('end_time').value = curHour + ":" + curMin;

var row = document.getElementById("start1_time");
var row1 = document.getElementById("end1_time");
var row2 = document.getElementById("start2_time");
var row3 = document.getElementById("end2_time");
                row.style.display = 'none';
                row1.style.display = 'none';
                row2.style.display = 'none';
                row3.style.display = 'none';

}
</script>

<script type="text/javascript">
function GetDate2()
{
        var curDateTime = new Date()
        var curHour = curDateTime.getHours()
        var curMin = curDateTime.getMinutes()
        if(curHour<10) curHour = "0" + curHour
        if(curMin<10) curMin = "0" + curMin
        document.getElementById('break_time_out').value = curHour + ":" + curMin ;
        var row = document.getElementById("end2_time");
        row.style.display = '';
}
</script>
<script type="text/javascript">
function GetDate3()
{
        var curDateTime = new Date()
        var curHour = curDateTime.getHours()
        var curMin = curDateTime.getMinutes()

        if(curHour<10) curHour = "0" + curHour
        if(curMin<10) curMin = "0" + curMin

 
        document.getElementById('break_time_in').value = curHour + ":" + curMin ;
       
}
</script>



<script type="text/javascript">
function tout1()
{
var temp= document.tracker.start_time.value;

if(temp.length>0)
{
var row1 = document.getElementById("end1_time");
var row2 = document.getElementById("start2_time");
        row1.style.display = 'none';
        row2.style.display = 'none';

}
else
{
var row = document.getElementById("start1_time");
var row1 = document.getElementById("end1_time");
var row2 = document.getElementById("start2_time");
        row.style.display = 'none';
                row1.style.display = 'none';
                row2.style.display = 'none';
}
}

function tout2()
{
var temp= document.tracker.start_time.value;

if(temp.length>0)
{
var row = document.getElementById("start1_time");
var row1 = document.getElementById("end1_time");
var row2 = document.getElementById("start2_time");
var row3 = document.getElementById("end2_time");
                row.style.display = 'none';
                row1.style.display = 'none';
                row2.style.display = 'none';
                row3.style.display = 'none';
}
else
{
var row = document.getElementById("start1_time");
var row1 = document.getElementById("end1_time");
var row2 = document.getElementById("start2_time");
var row3 = document.getElementById("end2_time");
        row.style.display = '';
                row1.style.display = 'none';
                row2.style.display = 'none';
                row3.style.display = 'none';
}
}


</script>

<script type="text/javascript">
var seconds = 0;
            var minutes = 0;
            var hours   = 0;
       
            function zeroPad(time) {
                var numZeropad = time + '';
                while(numZeropad.length < 2) {
                    numZeropad = "0" + numZeropad;
                }
                return numZeropad;
            }
           
            function countSecs() {
                 var j=document.tracker.hide.value;
                 if(j=="yes")
                 {
                seconds++;

                if (seconds > 59) {
                    minutes++;
                    seconds = 0;
                }
                if (minutes > 59)
                {
                    hours++
                    minutes = 0;
                               
                }
                document.tracker.time_utilization.value = zeroPad(hours) + ":" + zeroPad(minutes) + ":" + zeroPad(seconds);
                 }
                 else
                     {}
            }

            function startTimer()
            {
               
                action = window.setInterval(countSecs,1000);
               
            }
           
function s()
{
   
    document.tracker.hide.value ="yes";
    startTimer();
   
}

function p()
{
    document.tracker.hide.value ="no";
   
   
}
</script>

</head>
<body>

                                           
                                <form name="tracker" method="post" action="processor.php" onsubmit="return formCheck(this);">
                               
                               

                               
                                <label class="formFieldQuestion">Start Time&nbsp;*</label><input readonly class=mainForm type=text name=start_time id=start_time size='30' value=''> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="button" id="start1_time" style="width: 100px" Value="Start Time" onClick="javascript&#058;GetDate();s();"></li>
                               
             
                                <label class="formFieldQuestion">End Time&nbsp;*</label><input readonly class=mainForm type=text name=end_time id=end_time size='30' value='' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="button" id="end1_time" style="width: 100px" Value="End Time" onClick="javascript&#058;GetDate1(); p();" style='display: none'></li>       
                               
                                <input type="hidden" name="hide" />
                               
                       
                                <label class="formFieldQuestion">Break Time Out&nbsp;</label><input class=mainForm readonly type=text name=break_time_out id=break_time_out size='30' value='' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="button" id="start2_time" style="width: 100px" Value="Start Time" onClick="javascript&#058;GetDate2();tout1();p();"></li>          

                       
                                <label class="formFieldQuestion">Break Time In&nbsp;</label><input class=mainForm readonly type=text name=break_time_in id=break_time_in size='30' value=''>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="button" id="end2_time" style="width: 100px" Value="End Time" onClick="javascript&#058;GetDate3(); tout2();s();" style='display: none'></li>               
                               
                       
                                <label class="formFieldQuestion">Time Utilization</label><input class=mainForm type=text  name=time_utilization id=time_utilization size='30' value='' readonly></li>
                                        <br /> <br />
                               
                                        <input id="saveForm" class="mainForm" type="submit" value="Submit"  style="width : 100px"/>
                               
                               
                                </form>                        
                                                                                       
                                           
   
</body>

</html>

 


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group