QuestionQ10

Scripting and Automation

A developer needs to create an HTML table whose rows alternate background colors between white and red. The developer does not know how many rows will be sent in each email, so they use a loop and assign the RowCount() of the table rows to the variable @numerator.

What AMPscript logic should be used within the loop to determine the background color for each table row?

  • A %%[ IF MOD(@numerator,2) = 1 THEN SET @color = 'Red' ELSE SET @color = 'White' ENDIF ]%%
  • B %%[ IF SUBSTRING(DIVIDE(@numerator,2),l) = 1 THEN SET @color = 'Red' ELSE SET @color = 'White' ENDIF ]%%
  • C %%[ IF @numerator/2 = 1 THEN SET @color = 'Red' ELSE SET @color = 'White' ENDIF ]%%
Explanation

The AMPscript Mod() function returns the remainder after dividing one number by another. Testing Mod(@numerator, 2) = 1 identifies odd-numbered rows and assigns them red; all even-numbered rows receive white, creating alternating row colors.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!