Filling Input field using js
I'm trying to fill the hidden input field in hubspot form
tried using this code
Codepen: https://codepen.io/Abdul-Ahad-the-decoder/pen/KKYYyod?editors=1010
i'm not sure, what's going wrong here, can you please help
5 Replies
the hsform is inserting an iframe and loading the form in that. document.querySelector can't go into that iframe
you can try selecting the iframe using querySelector, then stepping in using, then using contentDocument instead but that only works in some circumstances depending on the iframe's site's crossorigin policy
also DOMContentLoaded will run before the iframe is loaded if im not mistaken
tried using contentDocument, still not able to get it, maybe due to the crossorigin policy then.
any other way I can try?
probably not, unless hsforms provides a way to send data into the form using the contructor thing in the html in your codepen