APIs & Integrations

Not applicable

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

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.

0 Upvotes
5 Replies 5
cbarley
HubSpot Alumni
HubSpot Alumni

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

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.

Not applicable

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

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.

0 Upvotes
cbarley
HubSpot Alumni
HubSpot Alumni

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

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.

0 Upvotes
JohnH2O
Participant

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

That's okay, was able to do it with another browser.

 

Strange how the HTML output is not well formatted like when the form is generated with javascript, though.

0 Upvotes
JohnH2O
Participant

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

Hi @cbarley do you still have this screen video you mentioned about how to get to the form HTML using the Chrome dev tools?  If you could post a link to that I'd certainly appreciate it.  Thanks.

0 Upvotes