# Populating a hidden field in a HubSpot form with Javascript

**URL:** <https://community.hubspot.com/t/populating-a-hidden-field-in-a-hubspot-form-with-javascript/116114>\
**Category:** APIs & Integrations\
**Tags:** forms, professional\
**Created:** [September 10, 2024, 6:25pm UTC](https://community.hubspot.com/t/populating-a-hidden-field-in-a-hubspot-form-with-javascript/116114 "2024-09-10T18:25:15Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![GRajput](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/grajput/32/102020_2.png) [@GRajput](https://community.hubspot.com/u/GRajput)\
**Post date:** [September 12, 2024, 10:04am UTC](https://community.hubspot.com/t/populating-a-hidden-field-in-a-hubspot-form-with-javascript/116114/4 "2024-09-12T10:04:50Z")

</div>

Hi @KKoch0

here is the code that works fine for me.

```lia-code-sample
hbspt.forms.create({
 region: "na1",
 portalId: "xxxxxx",
 formId: "xxxxxx",
 onFormReady: function($form) {
 // Wait until the form is fully rendered and fields are accessible
 setTimeout(function() {
 const assetField = $form.find('input[name="asset_requested"]');
 if (assetField.length) {
 //do your codinng here
 }
 }, 500); // Adjust timeout as needed for your form loading speed
 }
});

```

I hope this will help you out. Please mark it as **Solution Accepted and upvote** to help another Community member.  
Thanks!

---

_[View the full topic](https://community.hubspot.com/t/populating-a-hidden-field-in-a-hubspot-form-with-javascript/116114)._
