Created
July 26, 2018 17:17
-
-
Save acoyfellow/3eccbef3e90c62c33efbc8694653b949 to your computer and use it in GitHub Desktop.
How to add hidden fields into PhoneSites forms (add to your Tracking section)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var hiddenFields= [ // customize these. | |
{name: 'name1', id: 'id1', value: 'value1' }, | |
{name: 'name2', id: 'id2', value: 'value2' }, | |
]; | |
var formCheck = setInterval(myTimer, 100); | |
function myTimer() { | |
if(form && form.noValidate){ | |
clearInterval(formCheck) | |
hiddenFields.forEach(function(field){ | |
var hiddenInput= document.createElement('input'); | |
hiddenInput.type= 'hidden'; | |
hiddenInput.value= field.value; | |
hiddenInput.id= field.id; | |
hiddenInput.name= field.name; | |
form.appendChild(hiddenInput); | |
}); | |
}; | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment