Calculating total of inputs and displaying in expression

Calculating total of inputs and displaying in expression

  

Hi!

I have three input boxes

__input1__          __input2__       __input3___         __TOTAL__

I want total of input1, input2, input3 and assign it to __TOTAL__

(__TOTAL__) is an expression


I have set the onBlur property on every input field which have the value
total = input1+input2+input3

and expression __total__ is mapped to total

But the expression is not getting updated when the input box looses focus.


Please help!
Thanks in advance


Hi Adyita,

Is this a Mobile App or a Web App? If it's a Web App, you shouldn't use onBlur, it's not supported by the Platform, and you should use an OnChange event instead (in OutSystems, not using JavaScript).

Solution

Hi Adyita,


You should use the OnChange of the 3 inputs, create a screen action to calculate the total and use ajax to display the value.

Solution

You need to use AJAX refresh to show new total value.

Kilian Hekhuis wrote:

Hi Adyita,

Is this a Mobile App or a Web App? If it's a Web App, you shouldn't use onBlur, it's not supported by the Platform, and you should use an OnChange event instead (in OutSystems, not using JavaScript).

Sorry to mention, its a WEB APP


Hi Aditya,

Your inputs should be bound to variables. For readeability I also recommend to create a variable to hold the computed total and use it in the expression.

 On the OnChange event of each of the inputs you should call a screen action that computes the total value as VarTotal = VarInp1 + VarInp2 + VarInp3 an then use a Ajax Refresh action to update the expression in the screen. 


Cheers,

Tiago.

Tiago Gafeira wrote:

Hi Aditya,

Your inputs should be bound to variables. For readeability I also recommend to create a variable to hold the computed total and use it in the expression.

 On the OnChange event of each of the inputs you should call a screen action that computes the total value as VarTotal = VarInp1 + VarInp2 + VarInp3 an then use a Ajax Refresh action to update the expression in the screen. 


Cheers,

Tiago.

Thank you so much! I did exactly same with the hint from @Hugo Duarte!