Auto Refresh

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jay87
Forum Commoner
Posts: 61
Joined: Thu Jan 07, 2010 5:22 am

Auto Refresh

Post by Jay87 »

I want my calllist.php page to refresh every 120 seconds and to have a countdown on the page until the page will refresh...

Any ideas on how i can do this??
Jay87
Forum Commoner
Posts: 61
Joined: Thu Jan 07, 2010 5:22 am

Re: Auto Refresh

Post by Jay87 »

I got the page to auto refresh using:

<tr><meta http-equiv="refresh" content="120;url=calllist.php"></tr>


no idea how to get a counter though (from 120 secs)...

Help plz
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: Auto Refresh

Post by klevis miho »

Try to find a javascript counter, i'm sure it isnd hard to find one
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Auto Refresh

Post by Jonah Bron »

Code: Select all

 
<span id="countdown_box">140</span>
<script type="text/javascript">
function decrementNumber(){
    var t = document.getElementById('countdown_box');
    var r = parseInt(t.innerHTML);
    r = r - 1;
    t.innerHTML = r;
}
x = setInterval(function (){ decrementNumber(); }, 1000);
</script>
 
I think the <span> tag (or div, whatever) must come before the javascript.
Jay87
Forum Commoner
Posts: 61
Joined: Thu Jan 07, 2010 5:22 am

Re: Auto Refresh

Post by Jay87 »

That code worked a treat...!

any idea how i can add the text: This page will auto-refresh in: [countdown] seconds

?
User avatar
Grizzzzzzzzzz
Forum Contributor
Posts: 125
Joined: Wed Sep 02, 2009 8:51 am

Re: Auto Refresh

Post by Grizzzzzzzzzz »

Code: Select all

This page will auto-refresh in: <span id="countdown_box">140</span> seconds
 <script type="text/javascript">
function decrementNumber(){
     var t = document.getElementById('countdown_box');
     var r = parseInt(t.innerHTML);
     r = r - 1;
     t.innerHTML = r;
 }
 x = setInterval(function (){ decrementNumber(); }, 1000);
 </script>
 
?
Post Reply