APIs & Integrations

Kodish
Member

Hubspot Form with external Webpage - Issue

Hi All,

I have created hubspot form and hosted into webpage. And I have tried to customize the code based on our requirement.

Form has FirstName, LastName, Email, and Page Name (custom field - this field hidden). The value will populate dynamically in “Page Name” field from webpage. I have tried to use the below code,

hbspt.forms.create({
portalId: ‘3042190’,
formId: ‘2aa8ad7b-81a7-449e-8318-48cf1c26f4b8’,
onFormSubmit: function($form)
{
$(‘input[name=“page_name”]’).val(‘Brian’).change();
}

});

The value doesnot populate.

Please provide the recommendations to resolve this.

Thanks,

0 Upvotes
6 Replies 6
3PETE
HubSpot Employee
HubSpot Employee

Hubspot Form with external Webpage - Issue

@Kodish_Potti

I would execute that code on page load and not on the form submit to make sure the timing is right on that field getting filled in. You can’t backfill a field value after the form has been submitted.

an example could be.

$( document ).ready(function() {
    $('input[name="page_name"]').val('Brian').change();
}); 

Also why are you waiting for a change event to register to fill in the value and not just do it right away?

0 Upvotes
Kodish
Member

Hubspot Form with external Webpage - Issue

@pmanca,

I have tried your example code, it’s not working. Please advice me, complete this issue as soon as.

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Hubspot Form with external Webpage - Issue

@Kodish_Potti It was a snippet to hopefully give you some ideas on filling in the form on page ready instead of after the form is submitted. You need to make the call from another point in time then when you are currently doing it. Also I think you need to read up on .change() That doesn’t change the value of the form field it allows you to call a function on a ‘change’ event which right now you aren’t doing.

0 Upvotes
Kodish
Member

Hubspot Form with external Webpage - Issue

@pmanca,

That mean, I need to write code ie. change() function?. Could you please provide some article or reference link, If possible.

Thanks,

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Hubspot Form with external Webpage - Issue

0 Upvotes
Kodish
Member

Hubspot Form with external Webpage - Issue

HI All,

Still did not get correct solutions for my issue.

Please advice me.

Thanks,

0 Upvotes