Skip to content

Instantly share code, notes, and snippets.

@acoyfellow
Created July 26, 2018 17:17
Show Gist options
  • Save acoyfellow/3eccbef3e90c62c33efbc8694653b949 to your computer and use it in GitHub Desktop.
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)
<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