There are two issues here:
1. How to put PHP variables into javascript
2. How to put javascript variables back into PHP
Here is how I have done it...
1. Putting PHP variable into your javascript is easy, just echo them into the script wherever you normally would declare your script variables.
2. Putting the variables back into PHP is the tricky part. You need a script that will take the javascript variables and put them into variables that will be posted back to the server when the form is submitted.
Below is a simple example...
You can find a more complex example here...
http://beta.experts-exchange.com/Web..._20587955.html