Joe Audette is out on vacation this week, so I'll try to give you some "bronze" level support until he's back. I'm not a JS expert, but it may be possible to put your JavaScript code into a separate HTML instance on the page. I'd think the problem in that case would be reliably identifying and processing the fields and buttons of the form at runtime. You may also have an issue because there could already be a javascript onsubmit function tied to the form submit button for field validations. I don't know if you're allowed to define two onsubmit functions on a page.
Now, if you are able to write your own custom submission handler, then you will definitely have full power to do any post processing you need to. As a bonus, the submit post-processing can be done on the server side, and therefore it wouldn't break if the client has JavaScript disabled for some reason.
Hope that helps.
Jamie