I am having trouble populating a Javascript variable from PHP.
My index.php file is in typical form i.e.
<?php
function blah () {}
function doThis ($sUserID) {}
?>
<HTML>
<head>
<script src="test.js"></script>
</head>
show results
</HTML>
Trouble is I need to populate a Javascript variable (in the 'test.js' file) with a value called from a PHP function (which is in the php file).
I have tried:
var jsVar = '<?php echo doThis(sUserID)?>';
document.write("jsVar: ", jsVar);
But no result.
So how do I call the PHP function (in another PHP file) from test.js?
Thanks.