Hi, Sanford,
We have modified your javascript for our particular use case, where we want to hide the Marketing Opt-in checkbox on our forms for people who have already opted in. We are using the field Consent Status to control the Marketing Opt-in field. So if a person has Consent Status = Consent Obtained then hide the Marketing Opt-in checkbox. However, after implementing it on the page, it's not working as expecting. It's continuing to show the checkbox no matter what. The code is below. If you could take a look and see if there are any obvious issues I would greatly appreciate it. Thank you!
var DTO = new SimpleDTO({
domain: "advent.com",
dataSrc: "https://info.advent.com/data-transfer-page.html",
debug: true,
mode: "receive",
cb: function(instance) {
var mktoFields = DTO.getGlobal()["mktoPreFillFields"];
MktoForms2.whenReady(function(form) {
console.log(mktoFields);
if (mktoFields.Consent_Status__c === "Consent obtained") {
var marketingOptin = document.querySelectorAll("input[name=marketingOptin]");
marketingOptin[0].parentNode.parentNode.parentNode.parentNode.style.display = 'none';
}
DTO.cleanup();
});
}
});
// Consent obtained
// Consent not obtained
// Consent not required
// Unsubscribed
... View more