Hey, I'm very new to Campaign. I'm trying to hide a panel if the data that comes through matches a previous panel or the next panel. Essentially like this
<% if (targetData.Recent2Name == 'targetData.Recent1Name ' || targetData.Recent2Name == ' targetData.Recent3Name ') { %>
Don't show panel
<% } else {%>
Show panel
<%} %>
I know the above won't work but I was wondering if there's a way to sort this so the Recent1Name and Recent3Name are referenced correctly?
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Thanks for the response
I ended up creating the targetData as a var
So in the end the working (rough) code was
<% if (targetData.Recent1Name != '') { %>
Show Panel 1
<%} %>
<% if (targetData.Recent2Name != '') { %>
<% var aHotel1 = targetData.Recent1Name;
var aHotel2 = targetData.Recent2Name;
var aHotel3 = targetData.Recent3Name; %>
<% if (aHotel2 == aHotel1 || aHotel2 == aHotel3) { %>
Hide Panel 2
<% } else {%>
Show Panel 2
<%} %>
<%} %>
<% if (targetData.Recent3Name != '') { %>
<% var aHotel1 = targetData.Recent1Name;
var aHotel2 = targetData.Recent2Name;
var aHotel3 = targetData.Recent3Name; %>
<% if (aHotel3 == aHotel1 || aHotel3 == aHotel2) { %>
Hide Panel 3
<% } else {%>
Show Panel 3
<%} %>
<%} %>
Hi @AndyHu1,
Try with this following examples:
<% if (targetData.Recent2Name == targetData.Recent1Name || targetData.Recent2Name == targetData.Recent3Name) { %>
<!-- Code to hide panel -->
<% } else { %>
<!-- Code to show panel -->
<% } %>
-1.Variable referencing: Single quotes are used for string literals , not for referencing variables.
- 2. Use comments or script-based comments to indicate the sections for hiding or showing the panel.
If you want to do it with a div:
<% if (targetData.Recent2Name == targetData.Recent1Name || targetData.Recent2Name == targetData.Recent3Name) { %>
<div style="display:none;">
<!-- Panel content goes here -->
</div>
<% } else { %>
<div>
<!-- Panel content goes here -->
</div>
<% } %>
Remember to ensure 'targetData.Recent1Name', 'targetData.Recent2Name', 'targetData.Recent3Name' are available and correctly populated in the context where you are using this script.
Hope this suits.
Kind regards,
Celia
Thanks for the response
I ended up creating the targetData as a var
So in the end the working (rough) code was
<% if (targetData.Recent1Name != '') { %>
Show Panel 1
<%} %>
<% if (targetData.Recent2Name != '') { %>
<% var aHotel1 = targetData.Recent1Name;
var aHotel2 = targetData.Recent2Name;
var aHotel3 = targetData.Recent3Name; %>
<% if (aHotel2 == aHotel1 || aHotel2 == aHotel3) { %>
Hide Panel 2
<% } else {%>
Show Panel 2
<%} %>
<%} %>
<% if (targetData.Recent3Name != '') { %>
<% var aHotel1 = targetData.Recent1Name;
var aHotel2 = targetData.Recent2Name;
var aHotel3 = targetData.Recent3Name; %>
<% if (aHotel3 == aHotel1 || aHotel3 == aHotel2) { %>
Hide Panel 3
<% } else {%>
Show Panel 3
<%} %>
<%} %>
Views
Likes
Replies