How can I get the HTML for Javascript-Generated HS Forms?


#1

Hello,

I have the following simple script to generate HS forms on the fly (I have to remove the angle brackets or it will not appear here):

script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"
/script
script
hbspt.forms.create({
portalId: "123456",
formId: "######-####-####-####-#########",
css: ""
});
/script

I have used this third party site tool to try to get the HTML for the form, which is what I need:

It generates a whole lot of HTML that looks like it should work and was derived from HubSpot, but the HTML when used does not work. An error message only happens saying "something went wrong" and the form data could not be submitted.

Is there some other tool I can use that is fool-proof to get the form HTML when I have the Portal ID and Form ID? Is there a block of code I can run to get it myself, or another third party tool that will get HTML that works properly?

Thanks.


#2

Hi @John5, the best way to get the HTML is to place your form on a page, allow it to load, then use the Chrome Dev tools to copy the HTML markup and paste this into LeadPages. At the end of the day, if you have gotten the proper HTML and placed it into LeadPages, the error is likely with the receiving side of this.

I'd be happy to test this out on my end to make sure the copying of the HTML code is correct if you give me your HubID and the name of the form you're working on.


#4

Hi Connor, thanks for your offer to help with that. For the time being I have figured out how to do the css element there (except for the thank you message output after submit) and have found that I can make use of the javascript generated form for now. I may wish to take you up on that in the future, however, and I found it impossible to get the HTML using the dev tools feature with Chrome. It was all over the place and would not show a simple and coherent view of the form code.


#5

Hi @John5, sounds good! I'm able to walk you through how to get to the form HTML using the dev tools as I'm quite familiar. I can attach a screenvideo for your reference if you'd want it in the future.