FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Special Count Down Script

 


fromegame
Hello Again Laughing ,

I want to have a php/javascript script to count down in ONLY seconds. So that I can define an amount of seconds in PHP and javascript will make it dynamic.

Code:
123 seconds remaining


Like that, and dynamic.
I also want to make that if there are 0 seconds left, he can do an action.

Thanks
TheMasterCheaif
hmm lets see what i cant do nothing about the no action but i can do the timer


Code:

<?php
//varibles
$timer = 60;
//while function
while ($timer > 0){
$timer--;}

echo (You have $timer seconds left);

?>
hexkid
fromegame wrote:
I want to have a php/javascript script to count down in ONLY seconds. So that I can define an amount of seconds in PHP and javascript will make it dynamic.

Code:
123 seconds remaining


Like that, and dynamic.
I also want to make that if there are 0 seconds left, he can do an action.


I highly recommend you try the second door to your right Smile

Code:
<?php
$value = 123;
?>
<html>
<head>
<title>woohoo!</title>
<script type="text/javascript">
function action() {
  // do action
  alert('woohoo!');
}

function countdown(seconds, fx) {
  while (seconds > 0) {
    // do something that decreases seconds (and updates counter)
    if (Math.random() < 0.0001) {
      --seconds;
      // document.getElementById('counter').innerHTML = seconds + ' seconds remaining';
    }
  }
  fx();
}
</script>
</head>
<body onload="countdown(<?php echo $value; ?>, action)">
<p id="counter"><?php echo $value; ?> seconds remaining</p>
</body>
</html>



[ Edit: this post made me a "Senior FriHoster"!! WooHoo!! Smile ]
fromegame
hexkid wrote:
fromegame wrote:
I want to have a php/javascript script to count down in ONLY seconds. So that I can define an amount of seconds in PHP and javascript will make it dynamic.

Code:
123 seconds remaining


Like that, and dynamic.
I also want to make that if there are 0 seconds left, he can do an action.


I highly recommend you try the second door to your right Smile

Code:
<?php
$value = 123;
?>
<html>
<head>
<title>woohoo!</title>
<script type="text/javascript">
function action() {
  // do action
  alert('woohoo!');
}

function countdown(seconds, fx) {
  while (seconds > 0) {
    // do something that decreases seconds (and updates counter)
    if (Math.random() < 0.0001) {
      --seconds;
      // document.getElementById('counter').innerHTML = seconds + ' seconds remaining';
    }
  }
  fx();
}
</script>
</head>
<body onload="countdown(<?php echo $value; ?>, action)">
<p id="counter"><?php echo $value; ?> seconds remaining</p>
</body>
</html>



[ Edit: this post made me a "Senior FriHoster"!! WooHoo!! Smile ]


Ok, but it gives an error now, is that ok Razz?
hexkid
fromegame wrote:
it gives an error now

It doesn't for me.

http://hexkid.frih.net/frome.php


But, really this is much more a JavaScript issue than a PHP one. Please take your question to the appropriate forum.
tidruG
moved to this forum at the request of the thread-starter.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.