Hidden Rich Text field to show based on page URL | Community
Skip to main content
Mike_St_Louis
Level 2
August 13, 2019
Question

Hidden Rich Text field to show based on page URL

  • August 13, 2019
  • 1 reply
  • 2543 views

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 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!

1 reply

SanfordWhiteman
Level 10
August 13, 2019

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
August 13, 2019

Typical boilerplate? Minimum JS skills here.

SanfordWhiteman
Level 10
August 13, 2019
MktoForms2.whenReady(function(form){
form.addHiddenFields({
LastFormURL : document.location.href
});
});‍‍‍‍‍

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