As you probably understand there is no simple way.
PHP is run on the server, then a page is sent to the client. There JS is run.
So there is no natural or easy way to pass a JS variable to PHP. You can do as reddrum suggests, or you can use AJAX. AJAX would probably fit you better in this case.