Show Conditional Items with Hidden Field items and Rules
A recurring topic that comes up is how to reduce the number of similar forms in a Formsite account. A related question is how to display different items on a form for different visitors. Both questions essentially ask the same thing: How to show conditional items on a form?
Some practical uses for this technique include:
- Create one order form with multiple pricing tiers
- Display only relevant questions based on the link used to reach the form
- Show approval items to qualified visitors
- Allow certain visitors only to see certain pages
Form owners can create all of these forms by using Hidden Field items and Rules.
The method to show conditional items is by setting rules on each item. Most form items have a Rules tab that can apply item rules, or all of the form’s rules can be seen on the Rules page. Creating rules is covered on the Rules documentation page.
The choices for each item rule are ‘hide’ or ‘show’, although ‘show’ is the most likely choice in virtually every situation. Setting an item’s rule to ‘show’ when a condition is met causes it to be hidden until that condition occurs. The ‘hide’ setting does the opposite, i.e., it shows the item until the condition occurs to hide it.
Show Conditional Items
The condition for showing an item is always an answer to a previous question. Using the Rules, form owners can show items based on the text value in a Hidden Field item. Hidden Field items can be Pre-populated with a specific value, then item rules can use those values as conditions for other items.
Example: Wholesale & retail pricing
- To offer wholesale pricing (or any pricing different than standard), start by creating the order form normally.
- Next, add a Hidden Field item to the top of the form.
- Copy the pricing items that are different and edit the prices accordingly.
- Develop codes or keywords to identify the wholesale visitors.
- Create rules on the copied pricing items to show when the Hidden Field item’s answer matches the wholesale keyword.
- Create rules on the regular pricing items to hide when the Hidden Field item’s answer is the keyword.
- Copy the Pre-populate link from the form’s Share page.
- Paste into an email with the keyword in the Hidden Field’s value.
- Test by visiting the Pre-populate URL.
When set up correctly, the form will display the regular pricing to all regular visitors and wholesale pricing when the correct keyword is included.
Protecting the URL
Some form owners may want to obscure the keyword or otherwise prevent visitors from seeing and/or changing the pre-populated value. The best way is to embed the form into another page then use the prePopulate parameter in the embed code.
Another option is to use a URL shortening service like https://bit.ly to minimize the URL, although the form itself will display the value in the URL. Using a special code or unrelated word can also be effective in masking the intended action.