diff --git a/LinkedIn - Demo Form Autofill.html b/LinkedIn - Demo Form Autofill.html index 49c4ca6..3092c7d 100644 --- a/LinkedIn - Demo Form Autofill.html +++ b/LinkedIn - Demo Form Autofill.html @@ -4,14 +4,14 @@ 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 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) { var newInput = document.createElement('input'); newInput.style.position = 'absolute'; newInput.style.left = '-999em'; newInput.setAttribute('name', tagName + '-flag'); newInput.setAttribute('type', 'text'); - newInput.setAttribute('id', tagName + '-flag'); + newInput.setAttribute('id', tagName + '-flag'); newInput.style.display = 'none'; newInput._value = newInput.value; Object.defineProperty(newInput, "value", { @@ -259,9 +259,12 @@ ZM: 'Zambia', ZW: 'Zimbabwe', }, - country = document.querySelector("#Country"); + mktoCountryInput = document.querySelector("#Country"); // 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){ @@ -344,4 +347,4 @@ + data-field-title="Title">--> \ No newline at end of file