Originally posted by kamy99
If write a JS func, then you can not pass php vars to it. However, if you encode your JS within PHP, then you can.
What's that supposed to mean? "Encode your JS within PHP"? Write a Javascript emulator in PHP? That would be PHP running Javascript, not Javascript running PHP. Write a PHP emulator in Javascript? Possible, but I'd bet good money that no-one's ever done it (and would be just as limited in application and functionality as any PHP code translatable into Javascript). Have PHP write Javascript code in its output? It's not running anything. Rewrite your Javascript as PHP? It's not Javascript any more (and only occasionally does it make any conceptual sense to attempt such a thing).
PHP can send data to Javascript, by rewriting the Javascript on demand in its response to the browser's request for a page (which is the solution for this situation). But the only way Javascript can send anything to PHP is by causing the browser to make a request back to the server.
Neither can run the other, because they're running on totally separate machines with only an occasional http request/response between passing them.