# Trying to pull session values into hidden form module fields

**URL:** <https://community.hubspot.com/t/trying-to-pull-session-values-into-hidden-form-module-fields/20363>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [April 24, 2020, 10:32pm UTC](https://community.hubspot.com/t/trying-to-pull-session-values-into-hidden-form-module-fields/20363 "2020-04-24T22:32:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathan-s2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/nathan-s2/32/61905_2.png) [@nathan-s2](https://community.hubspot.com/u/nathan-s2)\
**Post date:** [April 24, 2020, 10:32pm UTC](https://community.hubspot.com/t/trying-to-pull-session-values-into-hidden-form-module-fields/20363/1 "2020-04-24T22:32:41Z")

</div>

I have a form module on a page that has some session values in play. The session values are set and stored with javascript to set values based on items the user has clicked on within the page… NOT within a form. It’s a multi-page process where various items are selected, then data is processed at the end after submitting a simple form. THAT ALL WORKS. But I’m trying to take these selection values and add them to the form in hidden fields so the submission record shows everything that the user selected prior to submitting the form.

I have a function that puts the session values into variables prior to running some calculations. Like this:

`var package = sessionStorage.getItem("package");`

I want to add code to this function where this variable is sent as the value of a hidden form field. From some Googling, I tried this:

```auto
hbspt.forms.create({
 portalId: "6040502",
 formId: "84dc8257-150c-4710-944d-587205ccd398",
 onFormSubmit: function($form){ 
 $("input[name='msp_package']").val(package).change();
 }
});

```

No matter what I try with this, nothing gets added to the form submission. I’ve got a missing piece somewhere.

---

<div class="post-metadata">

**Author:** ![nathan-s2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/nathan-s2/32/61905_2.png) [@nathan-s2](https://community.hubspot.com/u/nathan-s2)\
**Post date:** [April 24, 2020, 10:56pm UTC](https://community.hubspot.com/t/trying-to-pull-session-values-into-hidden-form-module-fields/20363/2 "2020-04-24T22:56:27Z")

</div>

Nevermind… I just figured it out. I’ll post it here in case someone comes along with the same need.

I had everything in place that I needed, but apparently my form was submitting BEFORE the script was running. So I changed “onFormSubmit” to “onFormReady” and now I’m in business! 🙂
