Speaking about the theory of this I was thinking about making a script that does something like:
Foreach field of the table fetch the field name, data type and length. Then generate the html tag according to this information.
I think this is quite easy to do.
The whole thing begins to get messy when you have to deal with styles and/or javascript handlers (onClick, onBlur, etc, etc...).