Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    Code:
    Countdown Timer:
    Database Backup in T-Minus 13 minutes 55 seconds!
    and counting down, however how can i make it refresh at the end when it hits zero, so that it refreshs the page without sending any forms

    i have a screen shot of what im trying to achieve if that will help at all?
    Last edited by Dan13071992; 01-22-2011 at 09:42 PM. Reason: changed the [code] tags so it was done properly

  2. #17
    Codeasaurus Rex
    Join Date
    Jun 2008
    Location
    Redmond, WA
    Posts
    660
    Thanks
    31
    Thanked 100 Times in 94 Posts
    Well I'll need some more clarification, what is your intention with refreshing the page? It is possible to make the page change location (which could be to itself), however without something else on the page this is kind of pointless.

    You can achieve this kind of behavior by doing this in the Javascript .get function.

    Code:
    if( data == "Database Backup in T-Minus 0 minutes 0 seconds!" )
         location.reload();
    Obviously there's ways to spruce this up in PHP. Such as making it display "Starting Backup!" when the minutes and seconds variables hit 0. Your coding level should allow you to do this without my assistance.
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com

  3. #18
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts


    that is what im trying to achieve, but when it hits 00:00 i would like the page to refresh itself, so that it is directed back to the same page but without sending any of the post data that was selected in order to start the timer, if that makes any sense

  4. #19
    Codeasaurus Rex
    Join Date
    Jun 2008
    Location
    Redmond, WA
    Posts
    660
    Thanks
    31
    Thanked 100 Times in 94 Posts
    So when the countdown is compelted you want to reload the page and then start the backup?

    If not, then you don't need to refresh. Just have PHP say something like:

    PHP Code:
    if( $countdownMinutes == && $countdownSeconds == ){
         echo( 
    "Backup Started!" );
         exit();

    If you still want to do the refresh, see my previous post for the code.
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com

  5. #20
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    in a way yes, sorry if i am confusing you, the only other way i can think of itt being done is if the box can be set to disappear from the page without a refresh, as it will be in a box like i have displayed?

  6. #21
    Codeasaurus Rex
    Join Date
    Jun 2008
    Location
    Redmond, WA
    Posts
    660
    Thanks
    31
    Thanked 100 Times in 94 Posts
    Yeah, you can do that easily with jQuery.

    Let's say your checkbox has an ID of "backupCheckbox".

    Then in the $(document).ready( function() { ... } block use something like this:

    Code:
    $("#backupCheckbox").hide();
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com

  7. #22
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    will that hide it when it gets to zero?

  8. #23
    Codeasaurus Rex
    Join Date
    Jun 2008
    Location
    Redmond, WA
    Posts
    660
    Thanks
    31
    Thanked 100 Times in 94 Posts
    If you combine it with what I already suggested. I really don't want to do too much in the way of coding for you here. The point is that you need to learn, otherwise if this breaks down you'll have no way to fix it or even modify it.

    In your jQuery AJAX you put a condition:

    Code:
    var refreshCountdown = 	setInterval( function() {
    						$.get( "/ajaxTimer.php", {}, function( data ){
    							if( data == "Database Backup in T-Minus 0 minutes 0 seconds!" )
    								$("#backupCheckbox").hide();
    							else
    								$("#countdownBlock").html( data );
    						});
    					}, 1000 );
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com


 
Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •