In this demonstration, we showcase events that can happen before and after the form is submitted. While still on the form, you can hide, display, disable and even set defaults for another field based on a response to a previous question. These are called Question Events. In contrast, Completion Events occur after the form is submitted and are also based on specific user responses. In this demo, you can either receive an email, get redirected to a page of your choice, or be added to a role.
Let's look at how these events are set up:
- Within the first section we have defined two question events.
- One question event is setup for the 'Hide work phone' checkbox as the question event postback field, an event type of 'Hide field', and an affected question of 'Work Phone'. Keep in mind in question events you can have as many 'Affected questions' as you would like, so we could have easily hidden multiple fields if we wanted to. Now, when you check this checkbox the Work Phone textbox should be hidden.
- One question event is setup to 'Disable web site' checkbox as the question event postback field, an event type of 'Disable field', and an affected question of 'Web Site'. Again, you can have multiple affected fields so if you wanted to disable multiple fields based on the postback question you can specify as many affected questions as you would like. There are also stylesheet properties setup for each field type when a field is disabled. This can allow you to alter the look (i.e. grey out) the field look and feel. These stylesheet properties are setup under the Module Configuration, Stylesheet settings. For textbox the stylesheet class is DynamicForms_DisabledTextBox. Now, when you check this checkbox the Web Site textbox should be disabled.
- In the second section, we have setup two question events.
- One question event sets the default values for the second question to 'No'. In this question event the postback question is the first yes/no dropdownlist and the affected field is the second radio button question. Although the affected field can be any field type (i.e. default a radio button, checkbox, checkboxlist, listbox, dropdownlist, or even a textbox) you can only specify one affected field for Default Value question events.
- One question event is setup almost the exact same as the first default value question event, however the postback 'Value' is set to 'Yes' instead of 'No'
- In the third section, we have setup two question events and also a field which will determine which form completion event will be fired upon form submission.
- The first question event setup for this section is setup to display a hidden field. To setup this question event we specified the dropdownlist field 'Would you like to execute a completion event' as the postback question, and the field 'Selection the completion event to execute' as the affected field. The question event type is 'Display previously hidden field'. In order to setup this event you must first go to the field which should be hidden and specify the checkbox 'Hide question until forced visible by question event. This setting is under Advanced Field settings within the specific field settings. We set the postback value which will trigger this event to be 'Yes'. With this event, the hidden question will never be displayed unless the post back value is Yes, in which case it will appear.
- The second question event is similar to the first question event to display a previously hidden field. This other hidden field is also setup under Advanced Field Settings to be 'Hidden until forced visible by question event.'. The field is setup to only be displayed if the user chooses 'Redirection' as the completion event type.
- Within this section we also are setting up which form completion event should be fired upon form submission. You can setup as many or as few completion events as you would like upon form submission and they can always be executed or be executed based on a fields response. In this example we are demonstrating several completion events.
- If you select the email completion event, the form results will be emailed to the email address you specified within section one of the form - View Screenshot
- If you select the redirection event, you will be redirected to a different page depending on the additional question to determine which page you want to be redirected too - View Screenshot
- Marking the checkbox, the role Form Demos will be added to your profile. Be sure to log in and then come back to Demo 9 where you will now see a text module that is only visible to this role.
Note: Question events cause a post back during form interaction (before submission.
See other Form Demos.