JavaScript If/Else Syntax:
Use if/else statements when you want to make different things happen depending
on different circumstances. Below is the syntax for an if/else statement in javaScript:
if (document.formMyFirstForm.txtMyStuff.size = = 30)
{
document.formMyFirstForm.txtMyStuff.size = = 20;
document.formMyFirstForm.btnMyOnlyButton.value = "My Button is Big";
}
else
{
document.formMyFirstForm.txtMyStuff.size = = 30;
document.formMyFirstForm.btnMyOnlyButton.value = "My Button is Small";
}
All lines of code are suppose to end with a semi-colon. It is just like a period
at the end of a sentence.
This is done so that you can place multiple commands on a single
line. Like this:
alert("hello world!");
alert("good-bye world");
Now anytime on the page that this function is called, the user will get an alert
box with the message
"hello world!" on it (along with the OK button).