Change Consent Language on Form Based on Country Selection | Community
Skip to main content
Level 3
June 25, 2025
Solved

Change Consent Language on Form Based on Country Selection

  • June 25, 2025
  • 2 replies
  • 743 views

We are testing marketo form embed on non-marketo pages. We have our consent language as a rich text field on the form.

How would we dynamically change the text of the consent language based on the Country field selection someone selects on the form? I looked at visibility rules for the rich text box, but could not figure out how to make it so if County = XXX, show new text. Default text will be visible and only change based on country selection..

 

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 SanfordWhiteman

You can’t switch content in the same Rich Text area, but you can create multiple Rich Text areas and then apply Visibility Rules to each so only one is shown at a time.

2 replies

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
June 26, 2025

You can’t switch content in the same Rich Text area, but you can create multiple Rich Text areas and then apply Visibility Rules to each so only one is shown at a time.

NiharikaGoyal
Level 3
June 26, 2025

⚠️  This post has been edited by a moderator for accuracy.
It’s our responsibility as a community to not provide AI-hallucinated and/or untested answers.

 

Hi @lizng2 Either you can use the visibility rule by creating separate rich text editor or better way if there are multiple countries then you can use the JS to show separate text of consent on basis of countries instead of creating separate multiple rich text fields. You have to add consent-text class in consent language rich text field. Here is the example of JS just for reference:

<script>
MktoForms2.whenReady(function(form) {
form.onChange(function(values) {
var country = values.values['Country']; // Replace 'Country' with your actual Marketo field API name
var consentText = document.querySelector('.consent-text');

if (consentText) {
if (country === "Germany") {
consentText.innerHTML = "<p>This is the GDPR consent text for Germany.</p>";
} else if (country === "USA") {
consentText.innerHTML = "<p>This is the consent text for USA.</p>";
} else {
consentText.innerHTML = "<p>This is the default consent text.</p>";
}
}
});

});
</script>

Hope that would helpful!!

Thanks!!

SanfordWhiteman
Level 10
June 26, 2025

Except this code does not work. onChange is not a function property of a Marketo form object, among other errors.

 

I assume the snippet was generated by a machine that doesn’t understand Marketo forms. Such content is not allowed here on the community.

 

While you can use JavaScript to manage HTML content in a Rich Text (provided the JS code is correct) there’s really no reason to go down that road here as it breaks your ability to use the Rich Text editor. It’s not the “better way” for that reason. Only if you had a very large number of language variants would this become easier to manage.