Conditions and repeating elements in code blocks
If you want the code block, or a portion of a code block, to be executed only if a certain condition
or conditions apply, use the following syntax:
<@ if (expression1) @>
code block1
[<@ elseif (expression2) @>
code block2]*
[<@ else @>
code block3]
<@ endif @>
The square brackets ([ ]) denote optional code and the asterisk (*) denotes zero or more instances.
The condition expression is any valid JavaScript condition expression, and may contain server
behavior parameters.
If you want the code block, or a portion of a code block, to be repeated a number of times, use the
following syntax:
<@ loop (@@param1@@,@@param2@@) @>
code block
<@ endloop @>
The loop directive takes a comma-separated list of parameter arrays as arguments. The repeating
text will be duplicated n times, where n is the length of the parameter array arguments. If more
than one parameter array argument is specified, all the arrays must have the same length. On the
ith evaluation of the loop, the ith elements of the parameter arrays replace the associated
parameter instances in the code block.
For general information on coding, see
Related topics
•
"Making code blocks conditional" on page 593
•
"Repeating code blocks" on page 594
Code block positioning within web pages
When you create code blocks using the Server Behavior Builder (see
Builder"
for more information), you must specify where to insert them in the page's HTML code.
You do this using the Server Behavior Builder dialog box's Insert Code and Relative Position pop-
up menus, which let you select where to insert the code block within the document, and then
specify a position relative to another tag in the page.
For example, if you insert a code block above the opening
code blocks position relative to other tags, scripts, and server behaviors in that section of the
page's HTML code. Typical examples include positioning a behavior either before or after any
recordset queries that might also exist in the page code above the opening
When you select a positioning option from the Insert Code pop-up menu, the options available
in the Relative Position pop-up menu change to provide relevant options for that part of the page.
For example, if you select Above the
positioning options available in the Relative Position pop-up menu reflect choices relevant for
that part of the page.
"Coding guidelines" on page
Tag in the Insert Code pop-up menu, then the
<html>
596.
"Using the Server Behavior
tag, you must then specify the
<html>
<html>
About custom server behaviors
tag.
591
Need help?
Do you have a question about the DREAMWEAVER MX 2004-USING DREAMWEAVER and is the answer not in the manual?
Questions and answers