HomeUsing FormSpringUsing FormsPre-Populating Form Fields

4.4. Pre-Populating Form Fields

Pre-Populating Form Fields

You can pre-populate fields on a form by appending data to the form URL. This could be helpful if you want to link users to the form from another form or application where you already collected some of the data from the user.

For example, the following will pre-populate a form with the name "John Doe" and phone number "555-5555":

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

A form URL like:

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

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

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

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



Notes:  This method of pre-populating form fields only works if you link to the form on formspring.com.  If the form is embedded on your own site, you will need to use the javascript embed method mentioned below.

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

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

This would look something like:  http://www.formspring.com/forms/?form=12345&viewkey=ABCDEF&name-first=John&name-last=Doe

Multiple options on a checkbox field can be populated by separating each option with a new line, which is encoded in the URL string as "%0A".  This would look something like:

http://www.formspring.com/forms/?form=12345&viewkey=ABCDEF&&fieldname=option1%0Aoption2

Pre-Populating Form Fields When Using The Javascript Embed

If you've embedding your form on your website using the javascript embed code instead of linking to it on our site, you'll have to use a different method to pre-populate your form data.  Take a look at the Use page for the form and the Form Forwarding tab. You should see some HTML code that contains something like:

<input type="hidden" name="form" value="1111" />
<input type="hidden" name="viewkey" value="ZZZZ" />
<input type="hidden" name="test" value="" />

In this example test is the name of one of the fields on your form. Now take a look at the JavaScript code you have to embed the form on your page. Taking a combination of that and what you get from the Form Forwarding tab you can build something that looks like:

<script type="text/javascript" src="http://www.formspring.com/forms/js.php?form=1111&viewkey=ZZZZ&style_version=2&test=VALUE"></script>

You can keep appending field names and values to the JavaScript src URL in order to pre-populate the form as embedded on the page.

Redirecting From One Form To Another

If you want to pass data from one FormSpring form to another FormSpring form, this can be done easily.  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 the second form's URL with your data appended and will look something like this:

http://www.formspring.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.



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.

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

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

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

Redirecting From One Form To Another Via E-mail

If you are creating a custom notification or confirmation e-mail to pass form fields onto a second form, the format for the link you create will be a bit different.  It will use the field numbers generated on the custom e-mail page.  Your link will look something like this:

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

 

This page was: Helpful | Not Helpful