How To Programatically Update Hidden Fields
It's now possible to programatically pass a hidden field value to Growform via JavaScript.
You may wish to do this if:
- There's a value on your webpage you wish to pass into Growform
- You need a tracking ID from an ad network or similar to be stored in Growform
- You wish to use the same form for multiple landing pages or websites, but wish to be able to tell them apart.
First, make sure you have a hidden field set up. Take note of its name (like "utm_source" - not the unique system ID), and then copy the following JavaScript code and place it above your Growform embed code -
<script type="text/javascript">
window.addEventListener('growform_loaded', function (e) {
growform.setHiddenField('myFieldName', 'myFieldValue');
}, false);
</script>
Replace 'myFieldName' with your field name (eg. "utm_source") and "myFieldValue" with the value you'd like to pass in. The single quotes should still appear in your code.
On form submission, you will then see this field populated along with other fields from your form!