Wow the way you are doing this may make sense in PHP but it is as far as you can get from webforms assuming that is what you are using.
If you are familiar with PHP I'd recommend using ASP.Net MVC over webforms but from the sound of what you are saying you've already started down the road of webforms.
The simplest way of taking what you have there and turning it into something that will work is first to start using jQuery because it will save you time with javascript, then remove the OnLoadEvent function from your aspx and use the script manager to register it in your code behind. In your javascript function you can then change the value of the hidden fields before submitting.
Although having said that, you are better off redesigning the page to work better with asp.net webforms. You could have the entire flow done on one page if necessary, using updatepanels or postbacks to update the screen. I'd recommend having a look at sample asp.net code and seeing how flow is handled because it's very different and will take a bit of getting used to.