Hide/show section on a condition
Dynamically showing additional questions (also known as in page branching) is really useful if you need to ask further questions based on an answer given on the page. You can do this by adding questions to a section and setting this section to show when a condition is met.
Example: Other title
This is a simple example of making a question show based on another question on the page.
A personal details page will usually have a question to collect the title of a customer, e.g. Mr, Mrs, Miss. This may be a dropdown type question, wehre we defined 'Mr', 'Mrs' and 'Miss' as options. However there are lots of other possible titles, that we may need to add to our dropdown, such as 'Professor' and 'Dr'.
To avoid having a really long list of options, we can add an 'Other' option that, once chosen, will trigger a text field question to be displayed. In this second question, the customer can specify their own title.
To do this:
Create a new page, and give it a title of 'Personal Details'.
Add a dropdown question to the page.
Set the question text to be 'Title' and add some answers e.g. 'Mr', 'Mrs' and 'Miss'.
And a new answer, 'Other'.
Save the question.
Drag a section on to the page below the 'Title' question.
Give it a title of 'Other Title'.
Leave the title hidden.
Choose to show this section conditionally.
Choose Question as the Show when
Then choose the Title question.
Choose is equal to.
Choose Other.
Save the section.
Drag a text field into the section, and give this question text of 'Your title'.
Save the question.
If you use this page in a form, you will find that the Your title question is hidden until you select Other from the Title dropdown.
Example 2: My address was not found
XFP provides a number of address lookup integrated components, where a customer can enter their postcode, and then select their property from a list. These lookups are powered by third party address services.
Sometimes, a customer may live at a property that is not known to the third party address service. Therefore, XFP's address lookup components always provide a 'My address was not found' option. When a customer selects this, it is often desirable to offer them the option of manually entering their address.
To do this:
Create a new page, and give it a title of 'Your Address'.
Add an Integrated question to the page.
Set the question text to be 'Address'.
Set the type to be the postcode lookup matching your configured address service.
Save the question.
Drag a section on to the page below the 'Address' question.
Give it a title of 'Manual Address'.
Leave the title hidden.
Choose to show this section conditionally.
Choose Question as the Show when
Then choose Address - UPRN (or property identifier, depending on the address lookup).
Choose is equal to.
Choose I cannot find my property.
Save the section.
In this section, you can now add questions to manually collect the address. You can do this either by sadding a text area, or by adding individual text fields for each line.
Conditions for showing and hiding sections
XFP supports a number of different conditions for showing and hiding sections. For example:
- Current day is ...
- Current date is ...
- Current time is ...
- Question is/is not answered
- Question answer is equal to ...
- User is signed in
- Submission is an internal form