# How do you get values from iFrame form?

**URL:** <https://community.hubspot.com/t/how-do-you-get-values-from-iframe-form/41381>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [July 27, 2021, 8:13pm UTC](https://community.hubspot.com/t/how-do-you-get-values-from-iframe-form/41381 "2021-07-27T20:13:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![charper\_floqast](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/charper_floqast/32/76463_2.png) [@charper\_floqast](https://community.hubspot.com/u/charper_floqast)\
**Post date:** [July 27, 2021, 8:13pm UTC](https://community.hubspot.com/t/how-do-you-get-values-from-iframe-form/41381/1 "2021-07-27T20:13:30Z")

</div>

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:

\<!--[if lte IE 8]\>

\<script charset=“utf-8” type=“text/javascript” src=“[//js.hsforms.net/forms/v2-legacy.js](https://js.hsforms.net/forms/v2-legacy.js)”\>\</script\>

\<![endif]--\>

\<script charset=“utf-8” type=“text/javascript” src=“[//js.hsforms.net/forms/v2.js](https://js.hsforms.net/forms/v2.js)”\>\</script\>

\<script\>

var firstName;

var lastName;

var businessEmail;

var phoneNumber;

var companyName;

var jobTitle;

var evalTime;

hbspt.forms.create({

region: “na1”,

portalId: “7800846”,

formId: “930a9a49-e26a-4e89-b379-4a628a2d78d3”,

onFormSubmit: function($form) {

firstName = jQuery(‘input[name=firstname]’).val();

lastName = jQuery(‘input[name=lastname]’).val();

businessEmail = jQuery(‘input[name=email]’).val();

phoneNumber = jQuery(‘input[name=number]’).val();

companyName = jQuery(‘input[name=company]’).val();

jobTitle = jQuery(‘input[name=jobtitle]’).val();

evalTime = jQuery(‘select[name=evaluation\_timeline]’).val();

// console.log(firstName, lastName, businessEmail, phoneNumber, companyName, jobTitle, evalTime)

alert(firstName, lastName, businessEmail, phoneNumber, companyName, jobTitle, evalTime)

}

});

\</script\>

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](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.

---

<div class="post-metadata">

**Author:** ![JBeatty](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jbeatty/32/52252_2.png) [@JBeatty](https://community.hubspot.com/u/JBeatty)\
**Post date:** [July 27, 2021, 9:37pm UTC](https://community.hubspot.com/t/how-do-you-get-values-from-iframe-form/41381/2 "2021-07-27T21:37:29Z")

</div>

Hi [@charper\_floqast](https://community.hubspot.com/t5/user/viewprofilepage/user-id/218421),

Since you are working within the onFormSubmit try using the $form instead of your jquery object.

```lia-code-sample
//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.
