is it posible to do a body on load from a php source to count down using anythingg, for instance php returns time left, count down from the time left.
cheers
is it posible to do a body on load from a php source to count down using anythingg, for instance php returns time left, count down from the time left.
cheers
php is serverside, it sounds like you want client side therefore javascript
i have already been told about this, however i dont know where i can get it to count down from, i know it can run through javascript, but i have no knowlegde of javascript.
Joopy;10941809 wrote:i have already been told about this, however i dont know where i can get it to count down from, i know it can run through javascript, but i have no knowlegde of javascript.
then a php forum is probably not the best place to ask :-)
Moving to the appropriate forum.
For core javascript and DOM references, see https://developer.mozilla.org/en/JavaScript. Do note that not all browser specifics are found there even though they sometimes tell you about IE non-conformance.
There are different ways to go about this.
In javascript_file.js
function countDown(counter) {
// code to deal with counting down, however that's supposed to work.
// [url=https://developer.mozilla.org/en/DOM/window#Methods]window.setTimeout() or window.setInterval()[/url] perhaps
}
echo '<script type="text/javascript" src="javascript_file.js"></script>';
echo '</head><body>';
echo '<body onload="countDown('.$counter.')">';
Or
javascript_file.php
echo 'var counter = ' . $_SESSION['counter'] . ';';
echo <<<EOS
function countDown() {
}
EOS;
echo '<script type="text/javascript" src="javascript_file.php"></script>';
echo '</head><body>';
echo '<body onload="countDown()">';
If you need the count down logic to be handled by php, you'd need to use ajax. Else, just set the counter variable in either of the above ways, and then implement the logic in javascript.