Sending Form Data from One Form to Another

Written by Formstack on February 6, 2009

Posted in Form Hacks

There may be times when you want to collect a small bit of information on one form and then redirect the user on to a second, longer form to collect more information. On the second form, you don’t want them to have to fill out any of the same info from the first form, so you want to pass on that data from one form to another.

Note: This method of forwarding form data from one form to another only works if you are linking to your forms on Formstack.com. It will not work if you have the forms embedded on your own website.

First, we need to learn how to pre-populate a form with data. The following URL, used to link to a form, will pre-populate it with the name “John Doe” and the phone number “555-5555”.

http://www.formstack.com/forms/example-form?name=John+Doe&phone=555-5555

A form URL like:

http://www.formstack.com/forms/?12345-ABCDEF

will need to be expanded into something like the following in order to accept appended data:

http://www.formstack.com/forms/?form=12345&viewkey=ABCDEF&name=John+Doe&phone=555-5555

To view the field names that are available for your form, go the Use page and click on Form Forwarding. Field names are generally lowercase versions of the field label, with the spaces and other special characters removed.

formforwarding

Now that we know how to pre-populate form data, we can move on to passing on data from one form to another. First build both of your forms. Next, create a submit action for your first form by going to Settings > E-mails & Redirects > After the Form is Submitted and creating a new submit action that says “Redirect to URL”. The URL you want to redirect to will be your second form’s URL with your data appended and will look something like this:

http://www.formstack.com/forms/?form=12345&viewkey=ABCDEF&name={$name}&phone={$phone}

The $name and $phone variables are taken from the field names, so whatever is typed into those fields on the first form will be passed on to the second form.

redirectform

In this example, the data from the name and phone number fields from form #1 would be passed on to those same fields in form #2.  You can pass on data from certain fields or all your fields, it’s up to you.  You can also pass data from one field into a different field on form #2 if you’d like.  For example, you could pass the name field data on to the phone number field if you wanted to for some reason.

For a real world example, say you want to create an online lead generation form. You wan to collect some information up front; name, phone number and email address, but would like to get all their information as well, like address, etc.  You could collect this important information on the first form and then pass it on to the second form.  If the user decides not to give you any additional info on the second form, at least you have the bare essentials you need to contact them.

Form 1:
leadgeneration1

Form 2:
leadgeneration2

Note: Since I wrote this blog post, Formstack has added new fields such as Name and Address that are groups of fields.  To pass this fields along, you would use the format below:

Name fields can be pre-populated with: -prefix, -first, -middle, -initial, -last, -suffix

This would look something like:  http://www.formstack.com/forms/?form=12345&viewkey=ABCDEF&name-first={$name-first}&name-last={$name-last}

Address fields can be pre-populated with: -address, -address2, -city, -state, -zip, -country