Jump to content

Count up appear in Textbox


demeritrious

Recommended Posts

I would appreciate if someone could figure this out or tell me the easiest way to do this. I need a count up counter that appears in a textbox so I can record the time a user is on a page. On a side note, I do have their Start and finish time timestamp recorded in myphpadmin database but I am looking for the easiest (or best) way to do this. Any advice or scripts would be very much appreciated.

 

Thanks in advanced.

 

I did find this counter that works but the numbers appear 0.0.1 if counting up. I don't want to confuse the user. I really want to display to the user how long they was on a certain page.

<script>
  $(document).ready(function() {
    var time = '00:00:00',
        parts = time.split(':'),
        hours = +parts[0],
        minutes = +parts[1],
        seconds = +parts[02],
        input = $('#timeInput');
 
    var timer = setInterval(function(){
        seconds++;
        if(seconds == 60) {
            seconds = 00;
            minutes++;
 
            if(minutes == 60) {
                minutes = 00;
                hours++;
            }
        }
        var newTime = hours + ":" + minutes + ":" + seconds;
        $('#timeInput').val(newTime);
    }, 1000);
 
});
</script>
 
<input type="text" name="time" id="timeInput"/>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.