First off, yes I know php only runs server side and only once before the page is output. That said, this should still work. What am I doing wrong?
MP3COMPETEjs.php (my JS file):
PHP/HTML (filename: index.php):
MP3COMPETEjs.php (my JS file):
Code:
Header("content-type: application/x-javascript");
//-----------blinking text
function blinkFont(obj)
{
document.getElementById("obj").style.color="red";
setTimeout("setblinkFont(obj)",1000);
}
function setblinkFont(obj)
{
document.getElementById("obj").style.color="<?PHP echo $color; ?>";
setTimeout("blinkFont(obj)",1000);
}
//----------end blinking text
PHP/HTML (filename: index.php):
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="../Javascript/MP3COMPETEjs.php"></script>
</head>
<body>
<?PHP
//For easier understanding, lets set $values and $color here.
//Though the whole reason i need to do this is because
//$values and $color are dynamic and based on
//data retrieved from a MySQL database.
$values = 0;
$color = '#0033FF';
if(time() - $values > 147600)
{
echo '<script type="text/javascript">blinkFont(blinkThis);</script>';
echo '<a id="blinkThis" href="CompSummary.php">' . $values . '</a>';
}
?>
</body>
</html>
Last edited: