This demonstration illustrates the ability to create dependent, data driven dropdown menus. This functionality allows the user to select a category from a dropdown menu, which when selected, populates another subcategory dropdown menu with the subcategories of the selected category. When the user selects a subcategory, this then populates a checkbox list with all the products associated with the selected subcategory.
In order to implement this functionality we will do the following:
Create the Questions
1) Create the "Category" question and set the following properties:
- Give it the name "Category"
- Give it the shortname "Category"
- Set the "Question Type" to "Combo Box"
- Select "SQL Driven Options" under "Question Options"
- Enter your SQL statement that will be used to fill the combo box
2) Create the "Subcategory" question and set the following properties:
- Give it the name "Subcategory"
- Give it the shortname "Subcat"
- Set the "Question Type" to "Combo Box"
- Select "SQL Driven Options" under "Question Options"
- Enter your SQL statement that will be used to fill the combo box, making sure the "WHERE" clause looks like this, "WHERE fieldName = $(Category)"
- Under "Advanced Field Options" check the "Hide until forced visible by question event" checkbox. This will ensure the "Subcategory" dropdown is hidden until the user selects a value from the "Category" dropdown.
3) Create the "Product" question and set the following properties:
- Give it the name "Products"
- Give it the shortname "Products"
- Set the "Question Type" to "Checkbox Group"
- Select "SQL Driven Options" under "Question Options"
- Enter your SQL statement that will be used to fill the combo box, making sure the "WHERE" clause looks like this, "WHERE fieldName = $(Subcat)"
- Under "Advanced Field Options" check the "Hide until forced visible by question event" checkbox. This will ensure the "Products" checkbox group is hidden until the user selects a value from the "Subcategory" dropdown.
Create the Question Events
1) Create a new question event that will execute when the user selects a "Category" and set the following properties:
- Call the event "SelectCategory"
- Select "Display hidden question based on another questions response" under the "Event Type"
- Select "Category" from the "initiation/postback question dropdown menu
- Check the "Execute event for any response" checkbox
- Check the "Subcategory" checkbox next to "Affected Question"
2) Create a new question event that will execute when the user selects the "Subcategory" and set the following properties:
- Call the event "SelectSubcategory"
- Select "Display hidden question based on another questions response" under the "Event Type"
- Select "Subcategory" from the "initiation/postback question dropdown menu
- Check the "Execute event for any response" checkbox
- Check the "Products" checkbox next to "Affected Question"
When it's all setup and working properly it should behave like the demonstration above.
Would you like to setup your form just as this demonstration is setup? If so simply download this template and copy it to your DNN Portals Home Directory to use the IPORTABLE feature of the module (Select Import Content from the module menu and import the template):