Good afternoon. We’re trying to pass values via hidden fields on a Hubspot form that we created. We set up the form along with the hidden fields and we have the embed code (below), but we’re still unsure how to pass those values from the web page on which the form appears. The challenge is the values that need to be passed in the form fields are dynamic based on the URL of the web page. We thought we may be able to pass them in this script block:
You can use jQuery to update the value of the hidden fields, like this: $('input[name="firstname"]').val('Brian').change();
Just make sure you’re updating the value of the fields after the form has finished loading. You can make sure this happens by putting your code in the onFormReady callback:
Jul 30, 20205:42 AM - edited Jul 30, 20206:00 AM
Member
Help with Hidden Fields in Forms
Unfortunately that is not a case anymore, any idea how can I hide hidden field and dynamically update it before submition ?
Your documentation isnt valid because solution shown in Docs isnt working
Equivalent of Vanilla JS is
var el = document.querySelector('[name="imported_from"]');
el.value='New Value'
el.dispatchEvent(new Event('change'));
And even though you can change element in DOM, input itself holding state inside React so split second before sending form input is changing to original prefilled input