• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

4. Variables, Functions, and Flow Contro... > 4.6. Branching Execution Based on Co...

Branching Execution Based on Conditions

NN 4, IE 4

Problem

You want your scripts to execute sections of code based on external values, such as Booleans, user entries in text boxes, or user choices from select elements.

Solution

Use the if , if /else, or switch flow control constructions to establish an execution path through a section of your scripts. When you need to perform a special section of script if one condition is met only, use the simple if construction with a conditional expression that tests for the condition:

if (condition) {
    // statements to execute if condition is true
}

To perform one branch under one condition and another branch for all other situations, use the if/else construction:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint