I also found out that sessions are the only way to send and recieve values between languages.
My question is:
How do I recieve session info in javascript?
Moderator: General Moderators
Code: Select all
<?php
function displayTimer($seconds) {
echo <<<EOD
<script type="text/javascript">
<!-- Hide JS from old browsers
var secs = {$seconds};
function doTimer(s) {
if (s > 0) {
document.getElementById('timer').innerHTML = s-1;
window.setTimeout(function() { doTimer(s-1); }, 1000);
} else {
window.clearTimeout();
}
}
document.write('<span id="timer">' + {$seconds} + '</span>');
doTimer(secs);
// End -->
</script>
EOD;
}
?>Code: Select all
<body>
Yadda yadda
<br />
Look it's a timer!
<p />
<?php
displayTimer(20);
?>
<br />
Yadda yadda