# form embed code value update onFormReady not working

**URL:** <https://community.hubspot.com/t/form-embed-code-value-update-onformready-not-working/14451>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [May 20, 2019, 8:28pm UTC](https://community.hubspot.com/t/form-embed-code-value-update-onformready-not-working/14451 "2019-05-20T20:28:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manobyte](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/manobyte/32/31851_2.png) [@Manobyte](https://community.hubspot.com/u/Manobyte)\
**Post date:** [May 20, 2019, 8:28pm UTC](https://community.hubspot.com/t/form-embed-code-value-update-onformready-not-working/14451/1 "2019-05-20T20:28:51Z")

</div>

So I have a form that I am creating with the embed code. When the form is created I need it to be created with a value already in it. I have done this in that past and not had any probles, so im not sure what is different or if I have a typo somewhere or something. So here is my code

hbspt.forms.create({  
portalId: “XXXXXX”,  
formId: “XXX-XXX-XXX-XXX-XXX”,  
target: ‘.firstform’,  
onFormReady: function($form) {  
$(‘input[name=“firstname”]’).val(‘Brian’).change();  
}  
});  
this creates the form but does not update the first name field with the value indicated, though I am sure I have used this method in the past. I also tryed using _onFormSubmit_ but that just submitted a blank form. Maybe something has changed?

---

<div class="post-metadata">

**Author:** ![Manobyte](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/manobyte/32/31851_2.png) [@Manobyte](https://community.hubspot.com/u/Manobyte)\
**Post date:** [May 20, 2019, 8:33pm UTC](https://community.hubspot.com/t/form-embed-code-value-update-onformready-not-working/14451/2 "2019-05-20T20:33:02Z")

</div>

Ok, so I may have posted pre-emtivly since I figureed out how to make this work. All I needed to do was turn on “unstyled form” in the forms options. and now it works.

---

<div class="post-metadata">

**Author:** ![Jenny](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jenny/32/24_2.png) [@Jenny](https://community.hubspot.com/u/Jenny)\
**Post date:** [May 21, 2019, 8:02pm UTC](https://community.hubspot.com/t/form-embed-code-value-update-onformready-not-working/14451/3 "2019-05-21T20:02:40Z")

</div>

Thanks for sharing your solution @Manobyte 🙂

---

<div class="post-metadata">

**Author:** ![Stevie-Kv](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stevie-kv/32/97206_2.png) [@Stevie-Kv](https://community.hubspot.com/u/Stevie-Kv)\
**Post date:** [December 10, 2020, 5:00pm UTC](https://community.hubspot.com/t/form-embed-code-value-update-onformready-not-working/14451/4 "2020-12-10T17:00:38Z")

</div>

Kudos to Manobyte for the shared solution. Been scratching my head for hours on this! It was the hint I needed to realise that JS and iframes don’t play nicely 🙂

---

<div class="post-metadata">

**Author:** ![dranreb](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dranreb/32/41549_2.png) [@dranreb](https://community.hubspot.com/u/dranreb)\
**Post date:** [August 8, 2019, 10:09am UTC](https://community.hubspot.com/t/form-embed-code-value-update-onformready-not-working/14451/5 "2019-08-08T10:09:41Z")

</div>

Thanks for your post and it’s great you got this to work.

I’m having an identical issue but _turning on_ **Unstyled form** did not help. Could you recommend something else for me to try? Thanks in advance for your time and any help you could offer with this request.

**Here’s my embed code:**

_\<!--[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\>_  
_hbspt.forms.create({_  
_portalId: “XXXXX”,_  
_formId: “XXXXX”,_  
_onFormReady: function($form, ctx) {_  
_jquery(‘input[name=“firstname”]’).val(“Brian”).change();_  
_}_  
_});_  
_\</script\>_

When I use _ **$** (‘input[name=“firstname”]’).val(“Brian”).change();_ I get an error _TypeError: $ is not a function_. So I replaced $ with jquery and that does not throw an error. This practice was recommended a few places as well. Maybe if you found a way around this error you could share it and that might resolve the issue for me.

---

<div class="post-metadata">

**Author:** ![Manobyte](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/manobyte/32/31851_2.png) [@Manobyte](https://community.hubspot.com/u/Manobyte)\
**Post date:** [August 8, 2019, 12:59pm UTC](https://community.hubspot.com/t/form-embed-code-value-update-onformready-not-working/14451/6 "2019-08-08T12:59:15Z")

</div>

I tested out the code you added, but unfortunaly I get an error when using _jquery_ instead of $. Ive never come accross the error using $ so im not sure how to tell you how to get around it. Are you loading the form on a hubspot page, or an external site? I was just building it on a hubspot page, which already has jquery added. So if you are building it on a separate site maybe there is an issue with the way jquery is loading?
