cat5ive, in terms of debugging, document.write is not always the best method because it will only write data to the page when the page is loaded. If you are debugging a javascript function that occurs after the page has been loaded like in response to a click event, document.write will not help you.
An alert box is useful for displaying information during javascript execution to give you the current value of a variable or alert you that the script has executed a particular piece of code, etc.
Example:
Code:
function myFunction() {
var myValue = document.getElementById('myField').value;
alert(myValue);
}
This would popup a message displaying the value of the form field myField. If the field did not exist though javascript would throw an error and code execution would stop and the alert would never occur.
You can also use try/catch blocks in javascript to test the execution of statements and catch/respond to errors so they do not cause execution to stop.
You can search on Javascript debugging or Javascript error detection or error trapping for more info.
Also, if you use Firefox you can use it's Javascript Console to give you much more information about any script errors that occur. It is very useful in tracking down and fixing bugs in the script.
At my age I still learn something new every day, but I forget two others.