I know this probably isn't the right place for this, but I see there are other FAQ type questions here so I thought it's as good a place as any? Moderators feel free to delete or move if need be of course. I understand, cleanliness, godliness, etc...
So I'm using a form on a page and above the form is some urgency copy, "Fill out the form to recieve your promotional offer now!" type deal. So what I'm trying to do or would like to do, is to target the form "Submit" button with .js so that I can make that header text disappear. So basically, target the .hs-button, and say that when it's clicked, to make the div which contains the "Fill out form to..." disappear.
I've tried several methods of attaching a command to the button but no matter how I target it, it simply won't perform the .js action. Trying to figure out what I'm doing wrong here. Code is below:
HTML: <body> <div class="form_container"> <div class="header" id="header"> <p>This is the header text for the form</p> <h3>THAT NEEDS TO DISAPPEAR</h3> </div> <div class="form"> <script charset="utf-8" src="//js.hsforms.net/forms/v2.js" type= "text/javascript"> </script> <script> hbspt.forms.create({ region: "na1", portalId: "someplacewithnumbers", formId: "xyzidentifyingthingamajigofcodethatgoeshere" }); </script> </div> </div> </body>
The .js code: function toggleText(){ var x = document.getElementByClassName(".hs-button primary large"); if (x.style.display === "none") { x.style.display = "block"; } else { x.style.display = "none"; } }
HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates. Learn More.
Ok, so I've tried @alyssamwilie's method. And that really does seem like it should work...but for w/e reason I can't get it to work :(. I don't know if I need to be running a separate script with it or not. I don't know if this is allowed will even work, but this is the fiddle I'm testing it in: https://jsfiddle.net/nlafakis/0wfvgjkn/232/. If that kinda thing isn't allowed I totally get it and no prob with removing.
So I'm sure you're going to find the code "sloppy," and that's because I'm not a veteran with html or css, but I'm fairly good at reverse engineering code, so I do a lot of copy/paste.
I've tried the onFormSubmitted method I've tried the onFormSubmit method
HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates. Learn More.
HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates. Learn More.
@nlafakis If you wanna target after form submission you'll want to use onFormSubmitted, this way it'll hide the header if the submission is a success (ie when the form submitted message appears)
Thank you so much! I will give this a try first since it seems to be the quicker solution, if not then I'll give Dennis' linked method a try and let you guys know which worked! Thanks again, really love this community and how responsive it is!
@alyssamwilie 's solution should be the correct one. (it is also listed on that link I provided)
onFormReady loads your function after the form is ready, onFormSubmitted loads it after the form has been submitted which is what you are looking to do. Thank Alyssa for correcting me 😀
HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates. Learn More.
Thanks for getting back to me! Ok, so this is for a registration form page. I'm using a different program to build the landing page, and I have the hubspot form within a container on the page. So you could think of it as:
<body>
<div (form background box)>
<h1>Some Headline Text Here</h1>
<div (hs-form)></div>
</div> </body>
So I'm trying to talk to the hs-form Submit button, and listen for when it's activated to make the "Some Headling Text Here" or <h1> copy, disappear or display: none; as it were. I know it's a SUPER long-shot and it's probably not even possible right? Because since it's a 3rd party page loading an exterior form, can it listen for it when the form is loaded on the page? Maybe the .js has to go at the footer so the form is already loaded? If it's not possible or seems not possible, I'm fine with that too, just wondering 😄
HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates. Learn More.
HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates. Learn More.