Page is a not externally linkable
usavetele - 10:55 pm on Jul 10, 2005 (gmt 0)
This is in my header: <? This is in my "script.php": <? var exchRate = 1.20379; <? This is what's in the body of my page, where the end result should be (note the "/", is this right or wrong?): <script language="javascript" src="/script.php"> getUSD('42.99'); </script> This doesn't work, but the following coding works if I add it below the coding directly above: <? alert("Woohoo! My javascript Works!"); <? Needless to say, I'm at a loss as to what the problem is. I know next to nothing about Javascript of course. Any help would be much appreciated! THANKS!
Ack, I can't get this to work:
session_start();
if(!session_is_registered('allow_script'))
{
session_register('allow_script');
$allow_script = true;
}
?>
session_start();
if($allow_script)
{
header("Content-type: text/javascript");
?>
function getUSD(price) {
var USD = price * exchRate;
if (USD.toFixed) { // check whether the browser supports that method
USD = USD.toFixed(2); // (2 is the required number of decimals)
} else {
USD = Math.round(USD*100)/100; // less perfect for older browsers
}
USD = '<b>USD $' + USD + '<\/b>'; // concatenation. escape the slash after the <
document.write(USD); // write the result
}
$allow_script = false;
}
?>
session_start();
if($allow_script)
{
header("Content-type: text/javascript");
?>
$allow_script = false;
}
?>