Im stuck with a JS calling out for some help. I have an embedded marketo webform and use the following Jscript to modify some behavior on submission: - hide form + custom thank you message - pass various consent values when field CandidateSOI =yes What I cannot figure out is to use multiple conditions to pass hidden values. More specifically, I would like to pass "Marketing_Consent_Mail__c": "Given", only when CandidateSOI=yes and an address was entered "Marketing_Consent_Phone__c": "Given", only when CandidateSOI=yes and a phone number was added "Marketing_Consent_SMS_Text__c": "Given", only when CandidateSOI=yes and a mobile phone was added. MktoForms2.whenReady(function (form) {
// turn off Munchkin cookie
form.addHiddenFields({"_mkt_trk":""});
form.onSubmit( function(form){
form.vals({"_mkt_trk":""});})
// pass mkt consent values Candidates
var consentObjCan = {
"Marketing_Consent__c" : "Given",
"Marketing_Consent_Email__c" : "Given",
"Marketing_Consent_Survey__c": "Given",
"Marketing_Consent_Mail__c": "Given",
"Marketing_Consent_Phone__c": "Given",
"Marketing_Consent_SMS_Text__c": "Given",
};
form.onSubmit(function () {
var consent = form.vals()["candidateSOI"] === "yes" ? true : false;
if (consent) {
form.addHiddenFields(consentObjCan);
}
});
//Add an onSuccess handler
form.onSuccess(function(values, followUpUrl) {
var email = form.vals().Email,
firstName = form.vals().FirstName,
lastName = form.vals().LastName,
html = "<div style='font-weight: bold; color: black; text-align: left;'>$firstName $lastName ($email) <br/><br/> wurde in die Datenbank eingetragen.<br/><br/>Seite neu laden mit: STRG + F5<br/><br/><br/></div>";
html = html.replace("$firstName", firstName);
html = html.replace("$email", email);
html = html.replace("$lastName", lastName);
document.getElementById("hidemessage").style.visibility = "hidden";
document.getElementById("showmessage").style.visibility = "visible";
$('html, body').animate({
scrollTop: ($('#yellowbox').offset().top)
},500);
// Get the form's jQuery element and hide it
form.getFormElem().hide();
// Return false to prevent the submission handler from taking the lead to the follow up url
form.getFormElem().after(html);
return false;
});
});
// ]]></script>
... View more