Example for widget calculation

Examples for widget calculation element

A mathematical calculation can be made with a calculation element. The widget creates a locked input field which is used to output the result of the calculation. In the properties of this field, a formula with field placeholders such as ([ % tf1% ] + [ % tf2 % ]) / 1.19 can be entered. In addition, the font color and output format for the result can be specified.

 

More information you will find in the FORMCYCLE help.

Example 1: Calculation

Subtraction of the values from tfValueDiff1 and tfValueDiff2.
Example: tfValueDiff1 - tfValueDiff2

Calculation of the gross amount with 16% - the value from "Result of the subtraction" (resultSubtraction) serves as the net amount.

Example: + ( * 0.16)

Summation of the values from tfValueSum1, tfValueSum2 and tfValueSum3.
Example: tfValueSum1 + tfValueSum2 + tfValueSum3

Example 2: String concatenation

Concatenation of the strings from tfString1 and tfString2 with a space in between.
Example: tfString1 + "  " + tfString2

Example 3: JavaScript function length

Use of the JavaScript function String.length
Example: t().toString().length

Example 4: Conditions

If the value in tfCondition is less than 2, "Bestätigt" is the output, otherwise "Abgelehnt".

Example: (tfCondition<2) ? "Bestätigt" : "Abgelehnt"

Example 5: Calculation in dynamic fields (function sum)

The sum of all values from the repeatable field will be calculated.
Example: $('.tfValueForSum').sum()

The placeholder [ % tfValueForSum % ], as in the previous examples, does not work for repeatable elements.

It have to be used a normal jQuery selector in this case, because the attribute name for repeated elements is data-org-name and not as usual data-name.


Summation of the fields tfValue1Dyn and tfValue2Dyn in a row.
Example: tfValue1Dyn + tfValue2Dyn

Example 6: Counting selected checkboxes

The selected checkboxes of the selection are counted. For this will be used a simple jQuery selector.
Example: $('[data-name=selOptions]:checked').length