We have done exactly the same thing
Some details changed but you should get the idea here.
Oh, forgot to mentioned, you need to be very careful with this depending on the size of your table.
The different browsers (IE, FF) rendering engine's performance varies greatly, so much in fact that we had to switch from the SDT to EDT when we were using image buttons because the rendering was so slow, and in fact we switched to a URL link instead of a button in certain tables where the number of rows is large because performance suffered so greatly.
Enjoy and have fun!