How to Dynamically Populate a Ranked Survey Field in Gravity Forms

Simplify your Ranking fields and make your surveys easier for your audience to complete.

This article requires the GP Populate Anything perk.

Buy Gravity Perks to get this perk plus 46 other premium Gravity Forms plugins!

View Plugin Buy Gravity Perks

Presenting your users with a list of items and having them rank those items is a helpful way to identify what your users value. Gravity Forms Survey Add-On provides an invaluable Rank field that allows your users to do just that.

Rank fields work best when you present fewer choices. The user has to make fewer decisions and split fewer hairs as they fret about whether or not they really do like apples more than oranges.

Save your users time and worry by having them narrow down their favorite choices first and only then rank their selected favorites.

This tutorial will demonstrate how, with the flexibility of GF Populate Anything, your users can select their top n choices in a Checkbox field and then rank those choices in a Rank Survey field.

Getting Started

We sell Gravity Perks. It’s a suite of 46+ powerful plugins (we call them perks) for Gravity Forms. Our Pro customers have unlimited access to all of these perks.

We’re conducting a survey and want to know which perks our customers value most. Rather than having them rank all 46 perks, we’ll let them first select their top 5 perks. Then we’ll populate the selected perks into a Rank Survey field, dramatically reducing the cognitive load to complete our survey.

Here’s how we can bring this to life.

Steps

  1. Create a Data Source Form
  2. Create the Survey Form
  3. Set Up the Survey Field
  4. Add the Snippet

Step 1 – Create a Data Source Form

Start by creating a new form. This is an administrative form; end-users will never interact with it. The data you submit in this form will be used to populate the Checkbox and Rank fields in our survey form.

Add a Single Line Text field to the form. In our case, we’ll label our field “Perk Name”.

Next, manually submit each choice that should be populated into the Checkbox field on your survey form. For us, that means we’ll need to submit this form once for each perk.

Step 2 – Create the Survey Form

Create the Survey form and add a Checkbox field to the form. Set up the Checkbox field to populate choices dynamically using entries from the data source form you created in Step 1.

A Checkbox field populated with list of perks

Step 3 – Set Up the Survey Field

Add a Survey field to the form and set up the Survey field to populate choices dynamically, also using the entries from the Data Source form. However, because you will want to populate the Survey field with only the selected Product, you’ll add a filter to only populate choices matching the selected checkbox option.

A Survey field populated with selected Perks

Go ahead and preview your form. You should have something that looks like this:

We use the “gf_list_4col” to put our checkboxes into four columns. This makes parsing the list of choices a lot easier.

Step 4 – Add the Snippet

Finally, add the following JavaScript snippet to the Survey form. When Populate Anything replaces the Survey options, it prevents them from being draggable. This snippet re-enables that.

$( document ).on( 'gppa_updated_batch_fields', function() { 
    gsurveySetUpRankSortable(); 
} );

We recommend using our free Code Chest plugin which lets you add form-specific JS like this right in the form settings.

Taking It Further

Require a Specific Number of Selections

If you want your customers to select a specific number of choices to populate the Rank field, use the GP Limit Checkboxes perk to set the minimum and maximum limit allowed for the Checkbox field.

Comments

  1. Ken
    Ken April 11, 2023 at 4:36 pm

    In Step 3, under the filter, we can see “Perk Name” “is” “Favorite Pe”. I assume that ‘Favorite Pe” is cut off, and is referring to “Favorite Perks, which is the checkbox field name? Would “is” be the correct condition to get the Rank field to dynamically populate the selected choices? Asking because I am unable to reproduce this example.

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff April 12, 2023 at 5:51 am

      Hi Ken,

      Yes, Favorite Pe, refers to the Favorite Perks checkbox field on the form. I just tested and confirmed the “is” operator still works. You can also try the “is in” operator if the “is” operator isn’t working. Also, ensure that the source form for the survey field is the same form you use to populate the Checkbox field. If you’re still having issues setting this up, you can contact us via our support form so we can look into this further.

      Best,

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Grab a bundle of free Gravity Forms plugins

Enter your email and receive our most popular free plugins and snippets, plus access to hundreds of others.

This field is for validation purposes and should be left unchanged.