ok well since the php is run as the page starts up you will need to reload the page to send the javascript to php, so you can whenever they do an action that would require the javascript var to be passed.
hmm maybe something like if you have a form
<form name=fred>
<input type=hidden name=whatever>
</form>
In javascript you can have a function run when the page needs to send the js value to php just use a function to give that var the value so like if they submit or something have a function set form.whatever.value='thevalue you want to send' then that value will be as whatever and be passed to php. I always need references to write js so that syntax is probably wrong go check out www.webmonkey.com js tutorial they have some good form changing value stuff
but jist, use a function to set the value of the tag or something and then when it goes off to the next php page it will be there.
Hope this will help i know it may not be the code and answer right here, but i think this could be a solution.
Good luck
ryan