Rule Manger widget is very expansive widget that can be very useful tool for TPC forms, and can be used to dynamically alter your forms based on a variety of instances. Basically, the rules manager widget allows you to set rules based on the user interactions to the widget. The Rules manager uses TPC Client side API to preform all the action.
Let’s look at some of the specific instances where we can use rules manager.
“Is Equal To” or “Is NOT Equal To” and Show / Hide Options.
“Is Equal To” or “Is NOT Equal To” allows Rules Manger to check the value of the widget (typically true/false, text or numeric values) and preform actions based on the value. The Show / Hide Options will let you display and hide the widget on the form. In addition, the “Is Equal To” and “Is Not Equal To” options are not case sensitive when targeting a widget.
Below is a basic form with a rules manager, set with number of rules.
In this form, we are using two TPC Text Box fields and a one TPC Rules Manager widget to demonstrate the functionality of the rules manager. The Objective is to display “Children’s name” field based on the value user enter in to “number of children”.
An order to accomplish this functionality we need to set up 3 rules in our Rules Manager widget.
- Hide the “children name “field on document ready/ Window load function triggers: this will hide the children names field on the initial Load of the form.
- Check if “number of Children” field is Not Equals to 0, if this condition is True then show the “children’s name” field. :- this will show if the user input a number in grater than 0 to the Number of children field.
- Check if “number of Children” field is Equals to 0, if this condition is True then Hide the “children’s name” field. :- this will hide the Children names field when the number of children filed is set to 0.
The “Changes” and “Run Script” Options
The “changes” option will trigger when the value of the set widget is changed. This can be anything from entering a different word in to the text box to different selection on a dropdown list. “Run Script” option will let the user run raw Java Script based on the event.
Below is a basic form with 3 Text fields, one rating filed and a Rules Manager. The objective is in this instance is to populate the rating field based on the “number of children” field value.
An order to achieve this functionality we need to have one rule in the rules manager; Run script on when the value of the “number of children” text field changes.
Script that we use in this instance is:
tpc.forms[0].numberofchildren.set_value(tpc.forms[0].numberofchildren_0.get_value());
When creating scripts in the rules manager there are three variables available for use in your scripts. These variables contains information relating to the trigger properties (When Field , When Event ,When Value)
Here are a detailed description of these variables: