Calculate the sum of values from multiple inputs

HI Team,

Is there a way to sum the values of multiple inputs to a result field.

For Ex: I have 7 input fields
once I enter the value in each of the input field say “input_textfield1” value is 10, input_textfield2 value is 20 like so on…, 8th input_textfield8 should display the sum of all the 7 input fields.

Thanks,
Sridhar

Hi @srjanga,

The easiest and best solution would be to create a new dedicated Interface Asset to address your specific need.

As of today, the closest Interface Assets available in Composer would be:

  • The Simple Counter: You could call 7 times the “Add” action to add the values from your text inputs. This would not require any code modification.
  • The Text Concatenation: You could bind 7 properties of this IA to your 7 text inputs, but you would need to make some modifications in the JavaScript code to make sure it does a numerical addition instead of concatenating the numbers as strings.

Let us know which path you choose!

Seb

1 Like

Hi Seb,

Thanks for the reply.
What we would want to do is the input fields have to be automatically sum and fall in the result field without adding a button to click the result.

Thanks,
Sridhar

Hi @srjanga,

Then the 2nd option is the best one.
I did the modification for you, you can download a sample here that contains a new NumbersAddition custom IA: NumbersAddition.zip (6.7 MB)

Usage is exactly the same as the Text Concatenation

Happy Monday!

3 Likes

Hi SEb,

Thanks for the example, sorry for the late reply.
we were looking similar to the one which you have suggested with little changes.

Regards,
Sridhar

Hi @srjanga,

Did you download the sample I shared in my previous message? Does that answer your need or did you end up creating your own custom Interface Asset on your side?