Jul 27, 2021 4:13 PM
Hi, I can't get values from my iframe form. I need to take extracted values and pass it to a third party api.
This is how I'm trying it:
Based on this answers this is how it seems you do it:
https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/td-p/326508
But my code doesn't work. I have confirmed my names are correct.
How do you get hubspot iframe form values.
Jul 27, 2021 5:37 PM - edited Jul 27, 2021 5:43 PM
Hi @charper_floqast,
Since you are working within the onFormSubmit try using the $form instead of your jquery object.
//Change this
firstName = jQuery('input[name=firstname]').val();
//To this
firstName = $form.find('input[name=firstname]').val();
I believe the issue is that by just using the "jQuery" object you are working within the object, and not within the form's iframe. Switching to use the $form object should place you in the correct scope.
Or if you wish to avoid using jQuery entirely you can use:
document.getElementById('hs-form-iframe-0').contentWindow.document.querySelectorAll('[name="firstname"]')[0].value
Just ensure that this form is the first and only form on your page, hence the "hs-form-iframe-0" id.
✔️ Was I able to help answer your question? Help the community by marking it as a solution.
![]() | Joshua Beatty Still have questions? Let's Talk |