Prepopulate 1 form from another form

  • Profile Image
    margaretluh
    Asked on November 29, 2012 at 11:09 PM

    Hi - I hope you are well! I am new to Jotform, and have limited programming skills. First, I want to tell you that I love the site, and your service is great --- you have a great tech staff! Here is my question.

    1. I am having problems creating prepopulated fields.

    2. I currently have 2 forms that I will refer to as "Form 1" and "Main Form" 

    "Form #1" is at http://www.jumpgifts.com/getstarted.html.

    "Main Form" at http://www.jumpgifts.com/submit2rt.html

    3) As you can see, "Form #1" is a simple signup form with just 4 or 5 lines. After a user hits "Submit". I want to take them to a new page "Main Form" with more questions for them to fill in. I would like 2 fields - the Email Field, and the Store Name field - on "Main Form" to be prepopulated with information from Form #1.

    I created that action by going into "Thank You" and selecting option 2 "Custom URL". In the custom URL, I redirected them to my new landing page (http://www.jumpgifts.com/submit2rt.html)  where the "Main Form" is located.

    4) Inside "Main Form", I wanted the "Confirm Email Address" {1Confirm} box to prepopulate from "Form #1" {email19} so I wrote the following code:

    <?php require 'header.html'; ?></div>

    <!-- title -->

    <br /> <div class="heading">About</div>

    RETAILER

    <div class="inner-text"><script type="text/javascript" src="//form.jotform.us/jsform/23338393134150?1Confirm={email19}"></script>

    5) The new form is not prepopulating.. It actually just writes out {email19} instead. Can you help me figure out what I did wrong?
    6) Also, If I want to prepopulate 2 different fields, how do I do that in the URL pattern?
    Thank you!

     

  • Profile Image
    fxr
    Answered on November 30, 2012 at 04:16 AM

    Hi,

    You will have to do this via php.

    --

    1. Enable POST vars for your 1st form by following this guide:

    http://www.jotform.com/help/51-How-to-Post-Submission-Data-to-Thank-You-Page

    2. Once that is done, you need to work out the variable name of your email field.

    ( There is a link in that article that you can use as temoporary thankyou page to see your forms posts POST variables )

    You can use this code to populate a php variable $email with the value of this field.

    $email = $_POST['email19'];

    3. You need to change the page that hosts your form to a php page, this is usually done by just renaming the extension from .html to .php.

     

    In the page, add this code at the start:

    <?php

    $email = $_POST['email19'];

     ?>

    --

    Then at the section that renders your form, change it to this:

     <script type="text/javascript" src="//form.jotform.us/jsform/23338393134150?1Confirm=<?php echo $email;?>"></script>

    --

    And that should be you done.

    It is a relatively simple process, even if it appears a little daunting to non-coders at first glance.

    --

    Let us know if you get stuck anywhere if you do decide to try this.