iFormBuilder Javascript Tips & Tricks
How do I calculate the difference between two Time elements?
Using Javascript, you can calculate the difference between Time elements. Follow the instructions below to implement the calculation on your form.
PLEASE NOTE: In this example, we'll be showing how to calculate the difference in minutes.
STEP 1. From inside the Form Builder, add two Time elements to your form. The first element will have a data column name of time1 while the second element will have a data column name of time2.
STEP 2. Add a Text element to your form. This is where your calculation will be performed.
STEP 3. In the Dynamic Value of your Text element, place the following syntax:
(Number(time2)-Number(time1))/60000
STEP 4. Save your form.
iFormBuilder Tip: To calculate the difference in hours, please use this syntax:
((Number(time2) - Number(time1))/60000)/60
For an easy to use example, please download this form package:
Comments
1 comment
The images in this article aren't appearing "/
Please sign in to leave a comment.