If I am understanding you right, no. It doesn't work because PHP is processed server side and Javascript is processed client side.
You can use PHP to dynamically write the Javascript before it goes to the browser, I do it all the time. But once it is gone, it is gone, and there is no way for PHP to process the variables unless you send them back to the server again using GET or POST.
Of course, I could be wrong.
A note that might change your mind a bit. Javascript is great, I use it extensively, but not everyone has it turned on in their browser. A lot of scares lately (most myths, once in a while real) has a lot of folks realizing that Javascript is turned on and how to turn it off. If you are writing a page that relies solely on Javascript to do this type of processing, best make sure you have an alternative means or you risk alienating some of your customer base.
Jim