Adobe is changing the world through digital experiences. Our creative, marketing and document solutions empower everyone â from emerging artists to global brands â to bring digital creations to life and deliver them to the right person
at the right moment for the best results.

To make colors alternate in a repeated region, you need to control the color attribute inside the tag that is repeatedtypically an HTML table row tag (<tr>) or an HTML table tag (<table>). For simplicity, this article assumes you applied the repeated region to a table row. Except for the HTML tag used, the information is the same for HTML tables.

The color attribute of the <tr> tag is bgcolorfor example, <tr bgcolor="yellow">. Your code must tell the application server to insert the bgcolor attribute in the <tr> tag every other time the tag is repeated.

Switch to Code view (View > Code) and find the beginning of the repeat region server behavior. To help you recognize the server behavior in the code, here's how Macromedia UltraDev 4 starts an ASP repeated region using VBScript:

<% While ((Repeat1__numRows <> 0) AND (NOT rsStaff.EOF)) %>

Once you've located the beginning of the repeated region, declare and initialize a record counter variable somewhere above the repeated region, as follows:

<%
Dim RecordCounter
RecordCounter = 0
%>

The record counter keeps track of the rows in the recordset as the repeated region loops through each record.

Next, enter the following script inside the first <tr> tag after the beginning of the repeated region:

The script starts by incrementing the record counter by 1. The expression RecordCounter Mod 2 reads the record counter's value, divides it by 2, and returns the remainder. If the remainder is equal to 1 (that is, if the row number is an odd number), then the application server inserts the string bgcolor=silver inside the <tr> tag. Otherwise, it does nothing.

The previous code creates a repeated region with a single added color: the application server inserts a bgcolor attribute in one <tr> tag, leaves out the bgcolor attribute in the following <tr> tag, and so on. To create a repeated region with two alternating colors instead of one, enter the following code:

In this code, the attribute's name is hard-coded in the HTML (<tr bgcolor=), meaning each row gets the attribute. The application server supplies the attribute's valuehere, silver or #FFCC66, a shade of orange.