next up previous
Next: for loops Up: JavaScript Control Statements Previous: JavaScript Control Statements

if ...else

Here's a typical example:

if(browser == "IE") {
document.alert("You're using Explorer");
}
else {
document.alert("Nope, that's not Explorer");
}

You might want to test for more than one possible condition at the same time.

In that case you must nest your

if ...else statements:

if(today == "Monday") {
its_monday();
}
else {
if(today == "Tuesday") {
its_tuesday();
}
else {
another_day();
}



Dave Marshall
9/28/2001