use Mkto setValues instead of setting 'value'

This commit is contained in:
Cappy Popp 2021-01-06 14:48:30 -05:00
parent dc2226bcdd
commit 6a0f231d1f

View File

@ -4,14 +4,14 @@
iframeHolderDiv = document.createElement('div'), // so we can style location of button iframeHolderDiv = document.createElement('div'), // so we can style location of button
autoFillLocation = document.querySelector("form[id^='mktoForm_']"), // will only find first Marketo form on a page autoFillLocation = document.querySelector("form[id^='mktoForm_']"), // will only find first Marketo form on a page
firstRow = document.querySelector('form .mktoFormRow'), firstRow = document.querySelector('form .mktoFormRow'),
hiddenLinkedInInputs = document.createDocumentFragment(), // since we're creating multiple nodes, just do the add once hiddenLinkedInInputs = document.createDocumentFragment(), // since we're creating multiple nodes, just do the add once
hiddenInputCreator = function (tagName, onChangeHandler) { hiddenInputCreator = function (tagName, onChangeHandler) {
var newInput = document.createElement('input'); var newInput = document.createElement('input');
newInput.style.position = 'absolute'; newInput.style.position = 'absolute';
newInput.style.left = '-999em'; newInput.style.left = '-999em';
newInput.setAttribute('name', tagName + '-flag'); newInput.setAttribute('name', tagName + '-flag');
newInput.setAttribute('type', 'text'); newInput.setAttribute('type', 'text');
newInput.setAttribute('id', tagName + '-flag'); newInput.setAttribute('id', tagName + '-flag');
newInput.style.display = 'none'; newInput.style.display = 'none';
newInput._value = newInput.value; newInput._value = newInput.value;
Object.defineProperty(newInput, "value", { Object.defineProperty(newInput, "value", {
@ -259,9 +259,12 @@
ZM: 'Zambia', ZM: 'Zambia',
ZW: 'Zimbabwe', ZW: 'Zimbabwe',
}, },
country = document.querySelector("#Country"); mktoCountryInput = document.querySelector("#Country");
// sets the value in the form the user can see // sets the value in the form the user can see
country.value = countries[newValue.toUpperCase()]; if (typeof MktoForms2 !== 'undefined') {
MktoForms2.allForms()[0].setValues({
'Country': countries[newValue.toUpperCase()]});
}
}); });
/*['email', 'country'].forEach(function(inputField){ /*['email', 'country'].forEach(function(inputField){
@ -344,4 +347,4 @@
<!-- what LinkedIn recommends which doesn't allow any customization --> <!-- what LinkedIn recommends which doesn't allow any customization -->
<!--<script type="IN/Form2" data-form="mktoForm_1248" data-field-firstname="FirstName" <!--<script type="IN/Form2" data-form="mktoForm_1248" data-field-firstname="FirstName"
data-field-lastname="LastName" data-field-phone="Phone" data-field-company="Company" data-field-lastname="LastName" data-field-phone="Phone" data-field-company="Company"
data-field-title="Title"></script>--> data-field-title="Title"></script>-->