Ok, here's a short hunk of code to paste into the
testing tool. Don't worry of you don't understand what everything does, just enter it in to get a taste of how it all works. I'll explain all the details later.. just make sure you enter it exactly as it appears here, semicolons and all. You don't have to be too fussy about indentation, though. Wimps can cut-and-paste, but you may benefit to type it in yourself, it helps commit it to memory.
I am intentionally avoiding the traditional "Hello World" approach on this one. It's an utterly exhausted cliché.
Code:
var prompt = "Click OK to change the background to red.\nClick Cancel to make it blue.";
if (confirm(prompt)) {
document.bgColor = "red";
}
else {
alert("We'll make it blue then.");
document.bgColor = "blue";
}
The parenthase-looking characters floating around, like the one after "else," are called curly-braces, and you get them when you hold Shift and hit the square bracket keys. There are a lot of curly braces in most programming languages, so get used to them.
So, paste this code in the tester, and click TEST. Assuming you typed everything correctly, you should see a dialog which does something different depending on what the user clicks. A very simple, very useless program. But if it's your first, then I am glad that I could be here to help you lose your programming virginity. I promise I'll call, I just have an early meeting, and need to go now...
In my next post, I'll start explaining what all the bits in the example mean, and some other basic programming information. But that'll probably be tomorrow morning sometime. Must sleep.