By: Andrew Gosnell Back to Guides
Hey, everyone! In this edition of Tips and Tricks, we’re going to look at how to display a varying number of fields in a registration form. We’ll do that by using Wufoo’s Rule Builder to create dynamic logic in the form.
Let’s suppose that we have a registration form where we want to allow multiple people to sign up, but the number could vary between entries. To begin with, we’ll put five Name fields in our form – enough for the registrant and up to four additional guests:
But what if someone is registering just two people in total? It would be nice if the form could display the appropriate number of Name fields. So let’s add a new dropdown field and find out how many guests our registrant will be bringing along.
Now we know the number of fields that we should be displaying, let’s go to the Rule Builder and create field rules on our form. For each of the name fields, we want to consider the conditions where the field should be shown.
First of all, the ‘Name 1’ field. We know that they will always be registering at least one person, so we don’t need a rule for that field – we want it to always be shown.
For the ‘Name 2’ field, it should be displayed if the registrant chooses the option for registering two people. But we also want to display the ‘Name 2’ field if they choose three, four or five people. For this, we’ll use multiple conditions to create the rule.
Similarly, we only want to display the Name 3 field if the registrant chooses three, four or five people.
And we continue in this way for the Name 4 and 5 fields.
And that’s all there is to it! When our registrant chooses the number of guests, they will see the appropriate number of Name fields thanks to our fancy new rules.
if you need to allow for more fields, it’s not a problem because this technique can be extended further. Just remember the general concept – start with the field you want to show and work out the lowest number where you should display that field. Make a condition based on that number and continue making conditions for every number higher than that.
Have fun making your dynamic registration forms!