APIs & Integrations

jasonabuck
Member

[SOLVED] Populate Form with Value while loading or $(document).ready()

How would I populate the hubspot form with a value either during or after page load.

If I link to http://www.mydomain.com/pagename.php?FormFieldName=VALUE

The Hubspot Form Field is populated with the VALUE.

How do I do this without passing the value in a querystring?

Thanks in Advance.

0 Upvotes
2 Replies 2
jwebgordon
HubSpot Employee
HubSpot Employee

[SOLVED] Populate Form with Value while loading or $(document).ready()

Hi Jason,

To figure out the selector for the field, you should just inspect the field on the page to find the name of that field, then you can use $('[name="X"]') as your selector. That name will be static for a given HubSpot field/property. As far as an event to time it with, I would recommend using $(window).load(). That will guarantee that the HubSpot form has had time to fully load before you try to populate the field.

Hope that helps!

jasonabuck
Member

[SOLVED] Populate Form with Value while loading or $(document).ready()

Thank you so much for your help.

That was what I was looking for. I found this in the documentation. http://developers.hubspot.com/manipulating-forms-with-jquery

below is my Javascript inside of PHP. Thanks million.

jQuery(window).load(function(){
   	jQuery(\'input[name="ei"]\').val(\'' . $DMWebinarID . '\').change();
    jQuery(\'input[name="webinar_type"]\').val(\'' . $WebcastType . '\').change(); 
	jQuery(\'input[name="webinar_primary_discipline"]\').val(\'' . $PrimaryDiscipline .  '\').change(); 
	   
    });
0 Upvotes