Pre-populate form with previous answers

  • Profile Image
    Asked on January 24, 2012 at 10:26 AM

    I'm working on a form for a client and so far I haven't been able to do what they've requested. But I'm pretty confident there is a way with Jotform - I just need some help. :)

    We would like the PREVIOUS submission from the same computer (IP) to pre-populate the form every time it's loaded. Users will fill out this form frequently, and only one or two items might change, so it will save them a ton of time if the form "remembers" their previous answers so they can make the minor edits necessary for the next submission.


  • Profile Image
    Answered on January 24, 2012 at 12:24 PM

    +1 This would be a really great feature.

  • Profile Image
    Answered on January 24, 2012 at 03:33 PM

    The only way I can envisage this being done, is with a self hosted database and the use of some php accessing both stored cookies and the database on your server  to a) populate the database and b) recognise (from a cookie) that this users PC has already filled in a form (on your site).

    The code to do this is by no means trivial, but its doable with a bit of patience and hard work. 

    We can help by giving an outline of the steps needed and providing some code but we may not have the time to coach you entirely through every detail of the process. 

    If you do wish to pursue the functionality, we will help as much as we possibly can though. The key step is building a mysql database on your server to host your form submission data. 

    You may get some idea of the what needs to be done from this User Guide Article one my colleagues created. 

  • Profile Image
    Answered on January 24, 2012 at 03:53 PM

    Thanks fxr! I had pretty much come to the same conclusion but wanted to check with you guys too. I appreciate the offer of help and I understand this is my responsibility, not yours. Any help would be appreciated.

    FWIW, I'm not using an actual database to hold form submissions, just a flat file. It works for this low-traffic site. And I can write submissions to it and read (IP number) from it to determine the user's previous answers. The part I'm puzzled by is how to then get the form to open in their browser with the data pre-populated. I saw the article about passing variables in the URL to pre-populate a form and that works when I type variables into my browser address bar. But I'm missing the PHP technique of how to cause PHP to open that same page with answers pre-populated. I hope that's not too confusing... :/

  • Profile Image
    Answered on January 24, 2012 at 04:19 PM

    It difficult to give precise advise here as I am not quite sure what your submissions text file looks like,

    but I would read the values of each forms fields into php variables; say I wanted to prepopulate a form with four text fields. 

    reg, kennelclub, dog, breed. 

    I would read the respective fields into variables from my text file ($regnum, $kennelclub, $kennel, $breed) then generate a form embed code with those fields prepopulated on the fly with this line of php. 

    echo '<script type="text/javascript" src="//'.$regnum.'&kennelclub='.$kennel.'&dog='.$dog.'&breed='.$breed.'"></script>';


    There is (many) other ways to do this, but do you think creating form embed code on the fly could work for you? 

    It does sound like you have a fair bit of the hard work done.

    The cookies/recognising a users IP address side of the equation should be fun :)

  • Profile Image
    Answered on January 24, 2012 at 06:31 PM

    THANK YOU, THANK YOU! You pointed me toward using the javascript embed code, which is the trick I was missing! I think I'm good-to-go (and a confirmed JotForm customer).

  • Profile Image
    Answered on January 24, 2012 at 06:45 PM

    Haha it was very much a pleasure. 

    You know where we are if you do need another nudge in the right direction. 

    All the very best to you sir.