# How to prepopulate promo code field and any other field in infusionsoft order form

**URL:** https://integration.keap.com/t/how-to-prepopulate-promo-code-field-and-any-other-field-in-infusionsoft-order-form/33571
**Category:** API Q&A
**Tags:** web-forms
**Created:** [March 13, 2018, 12:23pm UTC](https://integration.keap.com/t/how-to-prepopulate-promo-code-field-and-any-other-field-in-infusionsoft-order-form/33571 "2018-03-13T12:23:31Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Adam\_R\_Fromson](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@Adam\_R\_Fromson](https://integration.keap.com/u/Adam_R_Fromson)
#### Post date: [March 13, 2018, 12:23pm UTC](https://integration.keap.com/t/how-to-prepopulate-promo-code-field-and-any-other-field-in-infusionsoft-order-form/33571/1 "2018-03-13T12:23:31Z")

</div>

How can I prepopulate promo code field and any other field like name and email in order form. I findout some of the video but not sure from where i can get that code. If you guide me regarding this that would be great. This is the link for the video [Pre-populate Infusionsoft Order Form Values - YouTube](https://www.youtube.com/watch?v=5lfmNHItrUQ). Also I tried this solution but it is not working. [Is there a way to pre-fill an order form? - #9 by Tyler\_McMaster](https://integration.keap.com/t/is-there-a-way-to-pre-fill-an-order-form/10713/9)

---

<div class="post-metadata">

### Author: ![Carlos\_Ochoa](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/carlos_ochoa/32/2547_2.png) [@Carlos\_Ochoa](https://integration.keap.com/u/Carlos_Ochoa)
#### Post date: [March 13, 2018, 5:02pm UTC](https://integration.keap.com/t/how-to-prepopulate-promo-code-field-and-any-other-field-in-infusionsoft-order-form/33571/2 "2018-03-13T17:02:22Z")

</div>

Hi @Adam_R_Fromson,  
You should be able to use the javascript code in your “HTML areas” of your order form theme. You can also add the javascript to each individual form by editing the form and clicking the “HTML area” tab. I don’t have a link to this specific code that was used in the video but I would recommend using [searchParams](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams). If you aren’t famiilar, [this](https://developer.mozilla.org/en-US/docs/Web/API/URL) should also help you out.

For example, a purely javascript way to accomplish this **MIGHT** look something like:

```auto
window.onload = function() {
     var urlToParse = new URL(window.location);
     var promoCode = urlToParse.searchParams.get('promoCode');
     document.querySelector('#promoCode').value = promoCode;
  }

```

---

<div class="post-metadata">

### Author: ![Tim\_Turner](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/tim_turner/32/11121_2.png) [@Tim\_Turner](https://integration.keap.com/u/Tim_Turner)
#### Post date: [December 10, 2019, 6:35pm UTC](https://integration.keap.com/t/how-to-prepopulate-promo-code-field-and-any-other-field-in-infusionsoft-order-form/33571/3 "2019-12-10T18:35:18Z")

</div>

Extending what Carlos put on here… here is code to parse first and last name, and email from an incoming link. We are using this from another app that users click to “Buy” and then we pass these vars into the url.

Here’s a sample url to a form… you should be able to edit this to insert yourappname and yourformname, then edit what is passed in to “test it” manually.  
[https://yourappname.infusionsoft.com/app/orderForms/yourformname?firstName=Tim&lastName=Turner&emailAddress=myname@myemail.com](https://yourappname.infusionsoft.com/app/orderForms/yourformname?firstName=Tim&lastName=Turner&emailAddress=myname@myemail.com)

To get it to work though you have to  
Add this to your footer HTML area for the theme or in each individual order form.

---

<div class="post-metadata">

### Author: ![John\_Borelli](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/john_borelli/32/11880_2.png) [@John\_Borelli](https://integration.keap.com/u/John_Borelli)
#### Post date: [December 11, 2019, 10:42pm UTC](https://integration.keap.com/t/how-to-prepopulate-promo-code-field-and-any-other-field-in-infusionsoft-order-form/33571/4 "2019-12-11T22:42:42Z")

</div>

Ok, so a couple of issues here. This is two years later and likely will be buried in search from all that’s come after BUT in the event it isn’t, I’ve corrected your post because you didn’t use the code option so it would show (ie it’s hidden to all but admins).

Actually, I’ll try to repost it here because it’s not working to change your post lol

```
    <script type="text/javascript">
        window.onload = function() {
             var urlToParse = new URL(window.location);
             var firstName = urlToParse.searchParams.get('firstName');
             document.querySelector('#firstName').value = firstName;
             var lastName = urlToParse.searchParams.get('lastName');
             document.querySelector('#lastName').value = lastName;
             var emailAddress = urlToParse.searchParams.get('emailAddress');
             document.querySelector('#emailAddress').value = emailAddress;
          }</script>

```
