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

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. Also I tried this solution but it is not working. Is there a way to pre-fill an order form? - #9 by Tyler_McMaster

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. If you aren’t famiilar, this should also help you out.

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

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

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.

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.

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;