You can't do that in PHP...
PHP runs in the server and has no idea of the client's side.
Clicking a button and reacting to it must be done using forms.
You could do something like:
<form name='FormName' action='PHP_FILE_TO_EXEC.php' method='POST' enctype='application/x-www-form-urlencoded' onsubmit='return JS_FUNCTION();'>
If JS_FUNCTION is never returning TRUE then you will have created an event that will be running in javascript (you'll have called the JS_FUNCTION each time you will press the button.
Another thing you can do is to call the same PHP file you are in but with some parameters passed in the POST...
Hope this helps...