Hubspot Form with external Webpage - Issue


#1

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,


#2

@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?


#3

@pmanca,

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


#4

@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.


#5

@pmanca,

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

Thanks,


#6

Here is a link to W3Schools.

https://www.w3schools.com/jquery/event_change.asp


#7

HI All,

Still did not get correct solutions for my issue.

Please advice me.

Thanks,