Multiple "IF" conditions- conditional content in HTML | Community
Skip to main content
Level 2
December 12, 2024
Solved

Multiple "IF" conditions- conditional content in HTML

  • December 12, 2024
  • 1 reply
  • 758 views

We have 6 different blocks of code (that we are putting into personalization blocks) that a recipient could receive.  How would I code an if/else statement for these (including the 1 generic version = else?).  Would it be something like below?

 

<% if ( targetData.segmentCode == "A" )  { %>
<%@ include view='A' %>

<% if ( targetData.segmentCode == "B" )  { %>
<%@ include view='B' %>

<% } else { %>
<%@ include view='C' %>
<% } %>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ParthaSarathy

Hi @kristenco4 ,

<% if (targetData.segmentCode == "A" ) { %> Insert content here <% } else if (targetData.segmentCode == "B" ){ %> Insert content here <% } else if (targetData.segmentCode == "C" ){ %> Insert content here <% } else { %> Insert content here <% } %>

Reference document

1 reply

ParthaSarathy
Community Advisor
ParthaSarathyCommunity AdvisorAccepted solution
Community Advisor
December 12, 2024

Hi @kristenco4 ,

<% if (targetData.segmentCode == "A" ) { %> Insert content here <% } else if (targetData.segmentCode == "B" ){ %> Insert content here <% } else if (targetData.segmentCode == "C" ){ %> Insert content here <% } else { %> Insert content here <% } %>

Reference document

~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
Level 2
December 12, 2024

thank you so much for the quick turnaround!