The calculate attribute and tag allow you to perform mathematical operations and display the result directly inside fields.
Basic syntax
[number name="number_1"]
[number name="number_2"]
[text name="result" calculate="number_1 + number_2"]This will display the result of adding number_1 and number_2.
Static values
You can use numbers and mathematical operators (+, -, *, /, ()), for example:
[text name="result" calculate="(10 * 2) / 5"]Result: 4.
Dynamic values
It is also possible to use names of other fields instead of fixed numbers. As mentioned in the basic syntax. For example:
[text name="result" calculate="number_1 * number_2"]This will automatically display the multiplied value of those fields.
Using the calculate tag
You can also directly evaluate a formula in the value attribute with the calculate tag:
[text name="result" value={calculate(1 + 2)}]In short, the calculate attribute and tag make it possible to work with both dynamic values (field names) and static values (fixed numbers), offering flexibility for different kinds of formulas.