How do you write a value returned by external javascript to a file using PHP?


I have a table with a button which onClick calls an external javascript file, which calculates some values and returns them to the table. I need to then write that value back to a file using PHP without leaving the current page. Is there any way to do this? I thought about trying onChange, but I wasn't sure how ot make that work with php since it's usually a javascript call.

PHP is executed on your server the javascript file, even if external, is run on the client machine.

You can't use PHP on the client machine! You must use javascript to call a php script, stored in your server, that do what you need to.

You're on the good track, you need to use AJAX calls in your javascript.