I have a piece of javascript code and whenever i execute it, it shows on the bottom of the webpage "Error on page". How do i go about debugging it?
You're using Internet Explorer, right? Since you're only getting the "Error on page" message at the bottom, you must have the Advanced option "Display a notification about every script error" turned off. That's ok, because you can still view the details by double clicking on the icon/message at the bottom. It will open up a dialog, and you might have to click Show Details to view the error information. It gives you the line number and a brief description of the problem. That should get you started in debugging the problem.
I have some more information for javascript debugging. I use Firefox all the time, and they have a nice javascript console. If you don't have Firefox installed, I'd recommend it at least to test out your pages. In the Tools menu, you'll find the JavaScript Console, in which there's a history of error messages that have occurred. Like the IE dialog, it will report the line number and a message. The Firefox console messages are usually a little more detailed than the Internet Explorer messages. If you're feeling adventurous, then you can try out a really cool Firefox extension called JavaScript Debugger a.k.a. Venkman. https://addons.mozilla.org/extensions/moreinfo.php?id=216&vid=512 If you've ever used a debugger for other languages, you'll be able to use the tool easily. If not, then you might want to start by reading the FAQ http://www.hacksrus.com/~ginda/venkman/faq/venkman-faq.html