Hidden Fields and Calculations
Arclab® Web Form Builder
What are Hidden Fields?
- Hidden fields can either be added directly or contain the result
of a calculation.
- Hidden fields work essentially the same as input fields, except that
no input element is displayed for hidden fields.
- They are mainly used in connection with calculations and logic elements.
- If the hidden field contains the result of a calculation, it will be
updated as soon as one of the fields used for the calculation changes.
- As with all fields, access to the values or content is via the
field name in curly brackets, e.g. {Fieldname}.
- Just like input fields, hidden fields can be output or used
for further calculations.
Various output elements are available in the form for the output of hidden fields.
See also: Output Input und Hidden Fields
- Hidden fields are transmitted exactly like input fields and can be used in email and database.
Table of Contents:
Add a Hidden Field directly
Add a new element and go to "Hidden Fields":
Texts and Numerical Values
Go to "Hidden Fields" and add a "Generic Variable"
to your form.
The position in the form does not matter.
Each hidden field has a unique field name through which the content can be accessed. Field names are displayed in curly brackets within the program, e.g. {Name}.
A "Variable (Hidden Field)" can contain text as well
as a numeric value. When you create a new variable, the value is empty.
You can also preassign the variable with a numerical value or text in "Initial
Content". You can simply enter text (without quotation marks) or
a numeric value.
Hidden fields are displayed in "Design Mode" (see below), but they are not visible in "Preview Mode" and in the created form.
In the example above, a "Hidden Field" with the name "{MyField}" and the numerical value "0.19" was created.
Random Values
If you need a random value, you can also use the "Variable" or "Random Value" (Hidden Field) form element.
To do this, simply select the random value you want:
In the example above, the "{MyRandomValue}" field is to be preset with a random integer between 5 and 25.
If you need a unique random ID, you can use the form
element "UUID v4 (RFC 4211)".
This has the advantage
that the probability of duplicate values is very unlikely and is therefore
particularly suitable for order numbers or the like.
Combine Fields
With the form element "Special Elements" > "Hidden Fields" > "Combine Fields", a new hidden field is generated which contains a combination or sequence of fields and / or texts. This element is very versatile and can be used with texts as well as numeric values. In this case, however, there is no addition but a sequence of values.
Sample:
In the following example, a new hidden field with the name "{Name}" is to be created from the two input fields "{First_Name}" and "{Last_Name}".
If the user enters e.g. "John" as first name and "Doe" as last name the result {Name} would be "Doe, John".
Date and Time
The form element "Special Elements"> "Hidden Fields"> "Date and Time" is very versatile and can be assigned a fixed date as well as used to calculate the date. You can choose the date or time format, depending on whether you need the date, time or both:
Sample: Current Date
In the following example a new field with the name "{MyCurrentDateField}" is to be created, which contains the current date (and time).
Sample: Calculate Date and Time
In the following example, a new field with the name "{Departure}" is to be created, which should be the date 7 days after the arrival selected by the user in a date picker (calendar).
The input field {Arrival} is used here as the basis for calculating the
hidden field {Departure}.
Of course, you can also use another hidden
field of the "Date and Time" type as the basis for the calculation.
Calculations
Various elements for calculation are available in the program. You can find these under "Calculations":
- "Mathematical Expression" is used to calculate
numerical values. Both hidden fields and input fields can be used in
the formula.
The result of the calculation is a numerical value which is saved in a new hidden field. - "Calculate Date and Time" is used to add or subtract
a timespan from a base date.
The result is a date which is saved in a new hidden field. - "Timespan" is used to calculate a timespan, i.e.
the period between two date fields.
The result is a numerical value which is saved in a new hidden field. - "Age Calculation" is used to calculate the age
at the current time.
The result is a numerical value which is saved in a new hidden field. - "Combine Fields" is used to create a new string with the contents of other fields and text.
The calculations are automatically updated as soon as a value (field) is changed in the form.
Mathematical Expression
"Mathematical Expression" is used to calculate numerical values. Both
hidden fields and input fields can be used in the formula.
The result
of the calculation is a numerical value which is saved in a new hidden field.
Here you can enter any formula, either via the left block or directly.
To insert field contents, click "Insert Field" or just
type the field name in curly brackets, e.g. {Fieldname}.
Sample: Mathematical Expression
In the following example, the total price {Total} is to be calculated from the quantity {Q} times the price {PPU}.
- The quantity should be entered by the user in "My Order:". The edit box has the field name {Q}.
- The unit price is specified in the hidden field {PPU} and should
also be displayed in the form.
In this example, the field contents are output via the form element: "Output Elements" > "Text". - The result of the calculation is stored in a new hidden numeric field named {Total}.
The position of the hidden fields in the form is irrelevant. As you can
see in the screenshot above, the field contents are output above the calculation.
The position of calculations in the form is only important if several consecutive
calculations are performed.
"Number of Decimal Places" and "Decimal
Seperator" refer to the result output.
If your formula contains a number
with decimal places, always use a point as the decimal separator
and not a comma!
Timespan
"Timespan" is used to calculate a timespan, i.e. the period between two
date fields.
The result is a numerical value which is saved in a new
hidden field.
The start and end times are always required to calculate
a time span. These must be Date/Time fields.
You can
do this with visible input elements such as the calendar element or hidden
date/time fields.
Important: Days and Calendar Days
You can choose
between days and calendar days. When changing from winter to summer time
(DST), the day of the change has only 23 hours, which corresponds to 0 days
(1 day equals 24 hours) but 1 calendar day. It is important to understand
the difference between days and calendar days. The time is irrelevant when
calculating calendar days.