Formula

The extra element "Formula" can be used to create online calculators, calculate prices, as well as to calculate scores in tests. To add the "Formula" element to your form, go to the "Extra" elements in the form settings and you need to click on the selected "Formula" item or drag it to the right, then you will see the added element on the right:

Formula 1

After you have added the "Formula" element, click on the "Edit" icon and a pop-up window for editing this element will open in front of you:

Formula 2

In the "Prefix" field, you can enter the characters that will be output before the result of calculating the formula. In the "Suffix" field, you can enter the characters that will be output after the result of calculating the formula:

Formula 3

The following "Separator" field allows you to choose the display of numbers (for example, the amount to be deduced) in the form that you think is more correct for perception:

Formula 4

To make some calculations, you need to add certain fields to the form that will directly participate in the calculation formula. To enter the formula settings, click on the item of the same name:

Formula 5

A pop-up window with formula settings will open in front of you:

Formula 6

Before that, I added a few simple elements that will participate in the formula:

Formula 7

In the calculation formula settings, click on the "Add element" icon and a window with elements in the form will open

Formula 8

To multiply two elements, first select the "Width" field and add the "multiply" sign:

Formula 9

Next, add the second field "Height":

Formula 10

As a result, we can simply calculate the area:

Formula 11

You can also add various conditions to the formula by clicking on the "Logical condition" icon:

Formula 12

A condition will appear in the formula and click "Setup":

Formula 13

A window opens where click on the "Add expression" icon:

Formula 14

Next, the field for which you need to set the condition and specify the corresponding values:

Formula 15

For detailed instructions on creating an online calculator, you can see here.

The following functions are available in the "Formula" element:

  • exchangeRates() Converts a number from one currency to another
  • round() Returns a number rounded to the nearest whole
  • ceil() Rounds the number to the nearest bigger whole
  • floor() Rounds the number to the nearest smaller whole
  • roundUp() Rounds a number to the nearest multiple of a given number
  • min() Returns the smallest of several numbers
  • max() Returns the largest of several numbers
  • medium() Returns the average of several numbers
  • today() Returns the number of seconds from the current date
  • datetime() Returns the number of seconds from the current date and time
  • strlen() Returns the number of characters in a string
  • pow() Raise the number to a degree
  • ln() Natural logarithm
  • lg() Decimal logarithm
  • log() Logarithm of a number on any basis
  • sin() Sinus angle in radians
  • cos() Cosine angle in radians
  • tan() Tangent angle in radians
  • ctg() Cotangent angle in radians
  • mod() The remainder of the division of two numbers
  • countYears() Returns the number of years from the difference of two dates
  • countMonths() Returns the number of months from the difference of two dates
  • countDays() Returns the number of days from the difference of two dates
  • year() Extracts the year from the date
  • month() Extracts the month from the date
  • day() Extracts the day from the date
  • countRemainingDays() Returns the number of days remaining from the difference of two dates
  • countRemainingMonths() Returns the number of months remaining from the difference of two dates
  • date() Returns the number of seconds from the date from the parameters passed (year, month, day)
  • dateValue() Returns the total of all digits of the date

To choose to use the required function in the calculation, click the "Add function" button:

Formula 16

A list of available functions opens:

Formula 17

For example, let's choose the function max(), which returns the largest of several numbers. After adding the function to the calculation formula, the value (1,2) will appear:

Formula 18

Here you need to specify the fields among which the largest value will be selected:

Formula 19

In the strlen() function, you can specify, for example, a text field where the function will count the number of characters entered. To do this, click between the brackets:

Formula 20

And click add item and select the required field from the list:

Formula 21

Comments

Order turnkey form development

No time to figure out all the settings yourself? No problem!
Order web form development from us