Not in operator for conditional content inside HTML | Community
Skip to main content
Level 5
June 4, 2024
Solved

Not in operator for conditional content inside HTML

  • June 4, 2024
  • 2 replies
  • 1033 views

Hi there,

 

Is there a way to use not in operator for the below conditional content 

for example if language not in ("EN","FR","ES")

 

<% if (language == "EN" ) { %> <DIV id=en-version>Hello <%= recipient.firstName %>,</DIV> <DIV>Discover your new offers!</DIV> <DIV><a href="https://www.adobe.com/products/en">www.adobe.com/products/en</A></FONT></DIV><% } %> <% if (language == "FR" ) { %> <DIV id=fr-version>Bonjour <%= recipient.firstName %>,</DIV> <DIV>Découvrez nos nouvelles offres !</DIV> <DIV><a href="https://www.adobe.com/products/fr">www.adobe.com/products/fr</A></DIV><% } %> <% if (language == "ES" ) { %> <DIV id=es-version><FONT face=Arial> <DIV>Olà <%= recipient.firstName %>,</DIV> <DIV>Descubra nuestros nuevas ofertas !</DIV> <DIV><a href="https://www.adobe.com/products/es">www.adobe.com/products/es</A></DIV> <% } %>

 

Please suggest

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 _Manoj_Kumar_

Hello @rvnth  This will be the correct way

var features = '21,22,23,24,25,26,27,28,29,30,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51'; var featuresArray=features.split(','); <% if ((featuresArray.indexOf(targetData.schema1.feat_cd) < 0) && (featuresArray.indexOf(targetData.schema2.feat_cd) < 0) && (featuresArray.indexOf(targetData.schema3.feat_cd) < 0) && !(featuresArray.indexOf(targetData.schema4.feat_cd) < 0)) { %>

2 replies

_Manoj_Kumar_
Community Advisor
Community Advisor
June 4, 2024

Hello @rvnth 

 

Yes, You can do it like this.

 

var languagues='ES,FR,EN'; var my_lang='JP' if(languagues.split(',').indexOf(my_lang) < 0){ // //print your content here }
     Manoj     Find me on LinkedIn
rvnthAuthor
Level 5
June 5, 2024

Hi @_manoj_kumar_ 

Thank you for your reply. If I do not want to use the my_lang variable, can I implement something like the following? I need to test this.

 

var features = '21,22,23,24,25,26,27,28,29,30,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51' <% if (!(targetData.schema1.feat_cd in features) && !(targetData.schema1.feat_cd in features) && !(targetData.schema1.feat_cd in features) && !(targetData.schema1.feat_cd in features)) { %>

 

_Manoj_Kumar_
Community Advisor
_Manoj_Kumar_Community AdvisorAccepted solution
Community Advisor
June 5, 2024

Hello @rvnth  This will be the correct way

var features = '21,22,23,24,25,26,27,28,29,30,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51'; var featuresArray=features.split(','); <% if ((featuresArray.indexOf(targetData.schema1.feat_cd) < 0) && (featuresArray.indexOf(targetData.schema2.feat_cd) < 0) && (featuresArray.indexOf(targetData.schema3.feat_cd) < 0) && !(featuresArray.indexOf(targetData.schema4.feat_cd) < 0)) { %>
     Manoj     Find me on LinkedIn
LakshmiPravallika
Community Advisor
Community Advisor
June 5, 2024

Hi @rvnth ,

 

You can try this way 

<% if (language == "EN" ) { %>
<DIV id=en-version>Hello <%= recipient.firstName %>,</DIV>
<DIV>Discover your new offers!</DIV>
<DIV><a href="https://www.adobe.com/products/en">www.adobe.com/products/en</A></FONT></DIV><%
} %>
<% else if (language == "FR" ) { %>
<DIV id=fr-version>Bonjour <%= recipient.firstName %>,</DIV>
<DIV>Découvrez nos nouvelles offres !</DIV>
<DIV><a href="https://www.adobe.com/products/fr">www.adobe.com/products/fr</A></DIV><%
} %>
<% else if (language == "ES" ) { %>
<DIV id=es-version><FONT face=Arial>
<DIV>Olà <%= recipient.firstName %>,</DIV>
<DIV>Descubra nuestros nuevas ofertas !</DIV>
<DIV><a href="https://www.adobe.com/products/es">www.adobe.com/products/es</A></DIV>
<% } %>
<% else { %>
Your HTML Content

<% }%>

 

Regards,

Pravallika.