hi,
i was given a task to create a dynamic delivery but not to use the personalization block.
the task was to change certain content in a pre defined template based on gender.
help me out.
thank you in advance.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @him2 ,
In your predefined template > source tab, you can copy paste the below script and alter it with the requirement content
<HTML>
<HEAD>
</HEAD>
<BODY>
<P>Hi,</P>
<P>Gender: <% if ( recipient.gender == 1 ) { %>content for Male<% } if ( recipient.gender == 2 ) { %> content for Female<% } %></P>
</BODY>
</HTML>
By using the above script, Preview/Result:
Preview for Male Recipient:
Preview for Female Recipient:
And additionally you can use 'else' for default recipients or can add recipient.gender == 0 for defining content for gender as 'none specified'
Views
Replies
Total Likes
Hi @him2 ,
In your predefined template > source tab, you can copy paste the below script and alter it with the requirement content
<HTML>
<HEAD>
</HEAD>
<BODY>
<P>Hi,</P>
<P>Gender: <% if ( recipient.gender == 1 ) { %>content for Male<% } if ( recipient.gender == 2 ) { %> content for Female<% } %></P>
</BODY>
</HTML>
By using the above script, Preview/Result:
Preview for Male Recipient:
Preview for Female Recipient:
And additionally you can use 'else' for default recipients or can add recipient.gender == 0 for defining content for gender as 'none specified'
Views
Replies
Total Likes
Hi @him2,
If you cannot use a personalization block, one way to achieve dynamic content based on gender in a pre-defined template is to use conditional statements. You can use an if/else statement to check the gender of the recipient and display different content based on the result.
Here's how you can achieve using HTML and Javascript:
<div id="delivery-template">
<h1>Thank you for your order, [name]!</h1>
<p>Your [item] will be delivered to:</p>
<p>[address]</p>
<script>
var gender = 'male'; // or 'female'
var name = 'John';
if (gender === 'male') {
document.write('<p>Dear Mr. ' + name + ',</p>');
} else {
document.write('<p>Dear Ms. ' + name + ',</p>');
}
</script>
</div>
You can customize this example to fit your specific needs, including adding more conditional statements for other gender-specific content.
Views
Replies
Total Likes
Hi @him2,
Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies