I have a php variable which uses some preset functions from a CMS to give me a file location on a server.
Any help would be great,
for anyone and everyone who has an interest in literature
You can add the value of a php variable to js like this:
Than you can recall the rest of the code like you want, including file or adding the code directly.
echo "<script>var name_of_varible=$php_value;";</script>
I have tried to do exactly what this says and I cannot get it to work. Here is what I am trying to do and the code.The Game.php calls the first PHP file and gets the number from the dice, shows it on the screen but doesn't store it in the variable (which I have declared in Game.php as a global variable) for future use.
Here is the PHP code:
$response = mt_rand(1,6);
echo '<script>currentQuote = $currentQuote;</script>';//this not working
echo "currentQuote is:";
echo $currentQuote; //this shows on the screen fine
$output.='<script>currentQuote = '.$currentQuote.';</script>';//this working
$output.='<br />currentQuote is:';
$output.=$currentQuote; //this shows on the screen fine
use [code]YOUR CODE GOES HERE[/code] or burn in Hell
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)