I've seen this question asked a lot so I'll post a hint on it.

You cannot use an imac or any other all-in-one computer's display as an external monitor for another computer. The external display port does not work like the firewire port, it cannot be placed in "target mode" for attaching to another computer.

I know it's a shame to have a dead 20/24" imac with a good LCD panel and not be able to use it, but it's not possible. Best thing you can do is ebay it for the display - someone else out there has cracked their imac's display and will gladly buy it from you. (OR you can browse for someone that has a good imac with a cracked display they are selling - buy it and install your good panel)

It's technically possible to remove the panel, obtain the proper cables and backlight power, and construct an external display from it, and I have investigated this a few times, but the parts are difficult to get ahold of, there are no available guidelines or cross-references, adapters are impossible to find, and powering the backlight can be tricky. So while I won't say it's impossible, you're not likely to do it yourself unless you get very lucky and find a guide someone else has written to convert your specific panel.

Changing display panels has varying degrees of difficulty and a variety of unique challenges depending on what model you have. I suggest you investigate what is involved with the process before you start buying things.

imac g4: panel itself is not hard to replace and they're pretty cross-compatible with same model, but the three evil screws on the underside of the panel's outer case can be very difficult to remove. They are long machined screws, tapped into hard plastic, and are made of soft metal, removed using small hex tools. (which is pretty much all around bad news) If you get it apart and switched, you may not want to install any or all of the button screws.

imac g5 no isight: easy to change, not too much work. midplane comes right out. just make sure you route the wires properly and don't pinch anything

imac isight (white): panel itself easy to change, but getting the front bezel off can be tricky. I know how to do it the "easy way" but I have yet to see anyone else provide instructions even remotely approaching this technique. The "credit card" method sometimes works, and sometimes does not, it depends on how the clips sit behind the bezel.

glass imac: again the panel is easy to swap but the front bezel is a pain. More a case of needing additional care than fighting with it though. Yes, the shower suction cups really do work. Be careful with the glass, it's fragile and very dangerous if broken.

apple displays: probably not worth the attempt. The older acrylic (clear plastic) ones were meant to be taken apart, the newer ones are not. Try a different power pack before you give up on it. Probably easier to hack a fix if you have a bad power pack and don't want to buy a replacement pack.

The new 27" imacs CAN do this.  It requires connecting the displayport to anther powered-on mac and restarting the imac.