Help with Hidden Fields in Forms


#1

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:

< script>
hbspt.forms.create({
portalId: ‘3485016’,
formId: ‘53136bde-0f0e-470c-8563-116081228b22’,
css: ‘’
});
< /script>

….but it’s not clear if we can. Please advise?


#2

Hi @Mark_Jackson,

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: