how to perform addition of two numbers and show result in third textbox when user enters value from textbox

-2
how to perform addition of two numbers and show result in third textbox  when user enters value from textbox  
asked
2 answers
3

You have to create an entity with two attributes for the values and one for the sum. Put that entity in a dataview on your page and onchange recalculate and refresh the entity.

There are two ways of doing this. The first is using the attribute’s option to calculate the value using a microflow. The second only uses nanoflow, which gives you the best ser experience, since the result will update instantanious

  • Create a non-persistent entity ‘Summerize’ having attributes ‘NumberA’, ‘NumberB’, and ‘SumOfAandB’.
  • On your page, add a dataview with as datasource a nanoflow that:
  1. creates an object of entity ‘Summerize’ and 
  2. passes that object as output parameter
  • Add ‘NumberA’, ‘NumberB’, and ‘SumOfAandB’ to the dataview
  • Create a nanoflow (not microflow) with input parameter ‘Summerize’ 
  • Give ‘NumberA’, and ‘NumberB’ an OnChange-event that triggers a nanoflow that
  1. adds A and B into SumOfAandB
  2. refreshes the ‘Summerize’-object
answered
0

You need to take a couple of steps:

  1. Create a domain entity to containt the calculation

  1. You need to add the inputs on a page inside a data view control to bind the data. Also add a button to call the Microflow you need to do the calculation. 

 

  1. Create 2 Microflows. One Microflow will initiate a default Calc Object and return that to the data view when you load the app for the first time. Create a second Microflow that will change the object to set the value to the sum of the two inputs. 

MF1/NF1: (link/bind to the Data view) – use a nanoflow to process this in your browser (microflows execute on the server). 

MF2 / NF2: (Link to the button). I recommend you use a nano-flow to offload the calculation to your browser and not the server. 

The calculation happens in the Change Calc Action. See below:

 

Hope this helps :)

answered