Hidden Rich Text field to show based on page URL

Mike_St_Louis
Level 2

Hidden Rich Text field to show based on page URL

We are using one form for three different country pages. I have 3 rich text boxes that are hidden that contain a link specific to whichever country page( URL) the person accesses the form from so for example, if someone visits www.mysite.com/us/en/blog and goes to the form on that page, I need to have the embed form pick up the "us" portion of the URL and show the US specific text box. We then need the same to be for other country abbreviations as well. So the parameter rules to sho won't work, but was wondering if there was a specific script/way to help with this?

Thanks!

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Hidden Rich Text field to show based on page URL

Visibility Rules will work together with a tiny bit of JS. Create a hidden field on your back end (this is always recommended anyway) LastFormURL.

Make the other fields' visibility depend on this field.

Set the field value with the typical boilerplate.

Mike_St_Louis
Level 2

Re: Hidden Rich Text field to show based on page URL

Typical boilerplate? Minimum JS skills here.

SanfordWhiteman
Level 10 - Community Moderator

Re: Hidden Rich Text field to show based on page URL

MktoForms2.whenReady(function(form){
form.addHiddenFields({
LastFormURL : document.location.href
});
});‍‍‍‍‍

(You'd find this code elsewhere in Community if you search for "LastFormURL".)