We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Apr 3, 2019 6:54 AM
Hello partners!
I realised that the "ID" property have change and now they vary everytime you open a landing page. It used to always have an fixed ID with the form number and now it has atached 4 numbers at the end, wich they change every time you refresh the page?
I use the ID with the classical document.getElementById....
Someone knows what will happen with my old landing pages? Will their forms change too?
Thanks in advance.
Solved! Go to Solution.
Apr 4, 2019 2:50 AM
Hi!
You are right! This number is only fixed in the exported forms (snipped code), not in the created from hubspot directly. I realised that after...
Anyway, I've found a function to do the thing, you can see here:
https://www.webdeveloper.com/d/114892-getelementbyid-partial-ids
Thanks for your help! Bye.
Apr 3, 2019 2:58 PM
Hi @Hubsforero,
I'm not sure if the digits at the end of the form ID you're referring to is a recent change; I could do some digging to see when that was added. Do you have a page where that's not happening? My understanding was that the ID attribute of a form on a page is going to be the form's actual ID, with those 4 digits appended. If you're looking for only the form ID, could you instead search by the data-form-id attribute? In jQuery that's pretty simple. You could do something like this:
$("[data-form-id='9dc26cae-b3ee-6bdc-9066-a299cf7e835b']")
Or in vanilla JS you could do something like this:
document.querySelectorAll("[data-form-id='9dc26cae-b3ee-6bdc-9066-a299cf7e835b']");
...which will return a NodeList that you can loop through. For what it's worth, there's a helpful Stack Overflow thread on grabbing elements by data attributes here: https://stackoverflow.com/questions/15912246/access-data-attribute-without-jquery
Does that help with what you're trying to do?
- Leland
Leland ScanlanHubSpot Developer Support |
Apr 4, 2019 2:50 AM
Hi!
You are right! This number is only fixed in the exported forms (snipped code), not in the created from hubspot directly. I realised that after...
Anyway, I've found a function to do the thing, you can see here:
https://www.webdeveloper.com/d/114892-getelementbyid-partial-ids
Thanks for your help! Bye.