VDL Conditions
VDL Actions can update a variable based on an existing value. For the latest versions of these examples, visit
the FICO VDL Online Reference.
Toggle a Boolean Value
This example uses a Javascript variable (toggleVar) to toggle the vdl-var item value between true and false.
Code editor
<script> function toggleVar(vm) { vm.vars.AGenabled(!vm.vars.AGenabled()); } </script> <vdl-var name="AGenabled" value="=true"></vdl-var> <vdl-action-group name="toggleActionGroup"> <vdl-action command="toggleVar"></vdl-action> </vdl-action-group>
Execute an Action if a Value Evaluates to True
In this example, the second action only runs if the vdl-var has a value of true.
Code editor
<script> function display(vm, evt, value) { window.alert("Value is: " + value); } </script> <vdl-action-group name="doCalc"> <vdl-action command="=100"></vdl-action> <vdl-action command="=value * value" vdl-if="=vars.AGenabled"></vdl-action> <vdl-action command="display"></vdl-action> </vdl-action-group>
Using Conditions with an Action Group
It is possible to add a vdl-if conditional attribute to a vdl-action-group tag.
Code editor
<vdl-action-group name="groupHide" vdl-if="=vars.AGenabled"> <vdl-action command="='Hello'"></vdl-action> <vdl-action command="display"></vdl-action> </vdl-action-group> <button vdl-event="click:actions.groupHide">Show</button>