I have had several instances where the ability to set the default values for form fields would have saved me hours of integration time.
For example:
My client has 10 webinar pages each with its own unique thank you page. Our current form configuration (not-HubSpot integrated) redirects the user to the appropriate thank you page which contains the webinar requested for view.
I can already dynamically change the thank you page destination from the form embed code - but what I am looking for is to also set a hidden fields value inside the embed code as well.
For example the embed code would look something like this:
<script> hbspt.forms.create({ portalId: 'XXXXXX', formId: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', formFields: { fieldID1 : { value : "my value" }, fieldID2 : { value : "my value" } } }); </script>
Where the field ID parameters and their values would correspond to certain fields (hidden or visible) in the form. This would allow me to use a single form across multiple pages on my site and also be able to send through the correct values for certain form fields based on the action / content they requested on the site.
If you guys can do this - or if it is already possible and I didn't know about it - I would love you forever.
This method of setting default values using the form embed code doesn't appear to work for 'Dropdown select' fields. I've tested it successfully with a text field, but with drop down select, using the internal field name and the internal value, nothing happens on form load.
I was wondering if you could follow up on this - is there any way I can set a hidden fields value to contain a value that was filled out in the form previously?
For example, if someone put their company name as one of the answers to a question in the form, would you be able to make a hidden value of a website url incorporate that answer to be something like www.<company name>.com?
Yes, this could be accomplished with some custom JavaScript which checks whether specific fields are filled onFormSubmit and then copies the values to hidden fields.
Thanks for the solution @IsaacTakushi! One thing to call out here is that you have to 'Set as raw HTML form' in the form's 'Style & preview' settings for this to work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.