First you have to realise that javascript is client side program and php is a server side. PHP processes the page and sends it to your browser, javascript is run once the page is sent to you.
With this in mind, you can resubmit the page in a form with the javascript variables stuck in a hidden field somewhere.... or you can make another HTTP request with the variables tagged on the end..
ie.. as below:
newreply.php?s=&action=newreply&threadid=10214399