Dynamically Disabling Content
The Enable Expression attribute can be attached to a question and will grey it out depending on the result of its expression. If the expression returns True (1), the question it is attached to will appear as it normally would, but if the expression returns False (0), the question will still be visible but the end user will not be able to interact with it.
Example of a disabled question.
Enable expressions are evaluated whenever there is a postback to the server, for example when a button is clicked.
Implementation:
- Switch to the Definition tab.
- Add the target content, i.e. a question or response.
- Plan conditions under which target content should be disabled. If they do not already exist, create methods of making these conditions possible (e.g. assignment expressions).
- Create any design-time variables needed to support the enable conditions.
- Within the Definition tab, right-click the target item.
- Select Attributes.
- Add a new attribute with the type Enable Expression.
- Switch to the new attribute's Value panel.
- Use the Attribute Expression field to write an expression that, if your planned conditions occur, will return one of the trigger values mentioned at the top of this topic, causing the target content to appear disabled until a certain condition has been met.
- Click OK.
Enable expressions can be used on any question type that is visible on the front end.