Making javascript variable a PHP variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
elinews
Forum Commoner
Posts: 38
Joined: Tue Aug 14, 2007 7:18 pm

Making javascript variable a PHP variable

Post by elinews »

I made this javascript, which is printing a js array, a php variable ($java) (took out the "<"s so it would display):

Code: Select all

<script type='text/javascript'>

document.write(photo[0])

</script>
I am then inserting that variable into another like this:

Code: Select all

$image="$dir/$java";
This is creating the source for the image. And of course it outputs the full javascript code instead of printing the array when it is called upon in $image.

My question is how do I get the array name to show instead of the javascript code? I'm thinking it must be done with a function() . . .
Last edited by elinews on Thu Sep 13, 2007 2:47 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm not following. How is $image being used? Javascript runs once the script has finished running.
Post Reply