Hi Bdk
What that script does is call some JS code by using PHP to pass parameters to a JS script which resides in another file. It's just a way of maintaining state, something which PHP is particularly good at.
PHP is, however, server-side. It can't reload a page unless the user clicks on 'reload'. What you have to do is use JavaScript event handlers, which of course you can do in a PHP file.
PHP and JavaScript work very well together, you just have to be aware of what happens in the browser and what happens on the server.
HTH
Norm