is there a way to pause a while loop and display a message on each iteration?
Thanks, but there’s no opportunity to display a message. I’m on to rendering javascript in php.
This displays nicely, but there’s no var in it:
<?php
echo '<script type="text/javascript">';
echo 'alert("Hello World")';
echo '</script>';
?>
how do I get the php variable into the JS var when the JS is rendered in php?
$str = "Hello World";
echo '<script type="text/javascript">';
echo 'var str = ?????';
echo 'alert(str)';
echo '</script>';
$str = "Hello World";
echo '<script type="text/javascript">';
echo 'alert("' . $str . '");';
echo '</script>';
Or:
$str = "Hello World";
echo '<script type="text/javascript">';
echo 'var str = "' . $str . '";';
echo 'alert(str);';
echo '</script>';
Thanks kduv. That fits the bill!.
This is one for my topic scrapbook. This one is truly a keeper! I’ve been needing something like this for years. Before recently, I didn’t understand javascript well enough to even ask this question.
Another way in JS:
displayMessage(data);
setTimeout(function(){hideMessage();}, 4000);
The setTimeout() method will run the callback function hideMessage() after 4000 miliseconds. You could use AJAX to post to a PHP page in the callback if you wanted.
Steve