You can use another slot loading optical drive from another mac. However, it must be the same type. The only two macs that I know that used these types of drives are the iMac G3 slot loading (350mhz-700mhz), and the G4 Cube. Any more "modern" slot loader will not fit without modifications.
Hiya, I have an iMacDV G3 450 with a DVD drive. The thing to note is that they can not burn CD disks. That is if you are after a Combo or Super drive check that the form factor fits your iMac first.
I would think that an old drive from a Cube would be ok though.
What are you thinking of using the iMac for? Mine has not been used for a few years and the good lady is not happy with it floating around the house.
Also to ask another question, I'm upgrading the iMac a bit, so when I buy the RAM does it have to be ECC or non ECC, because I was watching a few upgrading videos and ECC didn't seem to work, so was just wondering if it made a difference or not.