Include custom javascript in the form
Sometimes we need to have a common function that must be called from several controls. For this purpose there is a new category in the scripts section called ‘Includes’. In this section you can write either javascripts that will be added in the form or change the default styles (CSS) with your desired style (See this article).
We have 3 controls a Number, a choice and a boolean (Yes/No) and their values affect the final result.
The first field is the Initial Amount(number), the second multiplies the initial amount and the third decides to double or not the final amount.First we create these 3 controls.
In the ‘Includes’ script section we must declare a function that calculates the final result and will be called from all 3 controls. This function’s code is
if (form.GetControl(“c_Double”).GetValue() == “1”)
result = result * 2;
Last thing to do is to go to the value change section of the 3 controls and call the above function.
The form and the calculation of the results in 3 steps (one step per control change) will be :
1.Initial Amount control
2. Multiply control
3. Double checkbox control and final result