User Guide

Server behavior techniques 289
Within the html tag, matching can also use position information. In the following example, there
are two participants, one that is added before the selection and another that is added after the
selection:
<% if (expression) { //mySBName %>
Random HTML selection here
<% } //end mySBName %>
These two participants are without parameters, so they are grouped together. However, you
can add another instance of this server behavior elsewhere in the HTML, as shown in the
following example:
<% if (expression) { //mySBName %>
Random HTML selection here
<% } //end mySBName %>
More HTML here...
<% if (expression) { //mySBName %>
Another HTML selection here
<% } //end mySBName %>
Now there are two identical instances of each participant, which is allowed within the HTML.
They are matched by the order in which they occur in the document.
The following example shows a matching problem and how to avoid it. You can create a
participant that computes the tax on some dynamic data and displays the result at the selection.
<% total = Recordset1.Fields.Item("itemPrice").Value * 1.0825 %>
<html>
<body>
The total (with taxes) is $<%=total%>
</body>
</html>
The two participants are matched because they have no common parameters. However, if you add
a second instance of this server behavior, you should have the following code:
<% total = Recordset1.Fields.Item("itemPrice").Value * 1.0825 %>
<% total = Recordset1.Fields.Item("salePrice").Value * 1.0825 %>
<html>
<body>
The total (with taxes) is $<%=total%>
Sale price (with taxes) is $<%=total%>
</body>
</html>
This server behavior no longer works correctly because only one parameter is named total. To
solve this problem, make sure that there is a parameter with a unique value and can be used to
match the participants. In the following example, you could make the
total variable name
unique using the column name:
<% itemPrice_total = Recordset1.Fields.Item("itemPrice").¬
Value * 1.0825 %>
<% salePrice_total = Recordset1.Fields.Item("salePrice").¬
Value * 1.0825 %>
<html>
<body>
The total (with taxes) is $<%=itemPrice_total%>
Sale price (with taxes) is $<%=salePrice_total%>
</body>
</html>
The search patterns now uniquely identify and match the participants.