First of all, your form tag doesn't have an action attribute. You need to tell it to send the form to itself.
But even if you do this, the script won't work. When the form submits, it refreshes the page, clearing all of the form values. Thus, the PHP-produced JavaScript wont work since none of those elements will contain values. This is not to mention that the JavaScript you have there doesn't follow the DOM.
Your PHP needs to reprint the values into the form.
I would suggest spending a lot of time learning the JavaScript DOM, it will help you make better code. Also, always try and fool around with your PHP as much as you can. The more you try and the more you mess up, the more you will learn!
-Peace!