PHP runs on a web server and is used to dynamically generate HTML that is sent to the web browser to display to the end user.
JavaScript runs within the web browser and allows you to modify things client-side while the user is using the web page.
Without JavaScript you would have to send a request to the server (to the PHP code) so that it could generate HTML based on the user's actions. JavaScript is faster and uses less bandwidth than posting back to the server....however JavaScript can't do everything (for example it can't connect to a database)
As Shenno was saying, JavaScript has a
document.getElementById() method that allows you to access an HTML element on the page. This method accepts a parameter: the ID of the HTML element that you want to work with.
So this means that your PHP script has to generate unique IDs for each HTML element that it generates...well, at least for the HTML elements that you need access to in your JavaScript code.
Please note that ID's for HTML elements must be unique on the page. Be aware of this when you are looping or you are calling other PHP scripts to help generate the code.
To get started, you may want to check out the
Offsite JavaScript Links thread that is sticky in the JavaScript forum.