Using FCF.FormCalc outside of a Repeater

Identify and group fields based on the calculations you wish to perform. In this example, input 1 and 2 will be addition, while input 3 will be subtraction. The grouped fields do not have to be within the same container.

Identify the field you wish to use as the output.

Apply classes unique to each of these groups. In this example the inputs in the blue container have the class “add” while the input in the green container has the class “subtract”. The output has the class “output”

Following the instruction in the FCF.FormCalc documentation, construct your FCF.FormCalc function call. In this example the function will add inputs 1 and 2, subtract input 3, and display the total in the output field. All this will be done within the scope of the outside/white container which has the class “calcs”.

FCF.formCalc('.calcs')('+', '.add')('-', '.subtract')('output', '.output');

Apply this function to the onchange attribute of the triggering field. This can be the surrounding container, a single field, or even a button. In this example it has been applied to the red container, in order to trigger when any of the inputs are entered/changed.

Now publish the changes and verify that it works!