Uh, well, I don't quite see the point of changing the fields value before the user hits submit. This means basically that it's very easy to tamper with (any idiot can disable javascript and give bogus values, remember that.).
Why not submit the form, then in PHP calculate the value?
If you have a good reason for doing this client-side, a hint would be to create a javascript function and launch it with an onClick="" event on the submit button.