That is not possible. To help you understand why I will try to explain how PHP and JavaScript works.
PHP is fun on the server, and sends code to the browser.
JavaScript is run on the browser, and the code is like normal HTML code.
When PHP is done everything is sent to the browser, after that the browser runs the javascript. So when the javascript is run there is no longer any connection to the server, and javascript can't transfer variables to PHP.