Forum Academy Marketplace Showcase Pricing Features

Do simple calculations

Opera Snapshot_2022-01-09_220817_bmw-beta.bubbleapps.io

So, i have an input which is set to currency (value in Initial content)
and have two icons (+) and (-)
I want when + is pressed the value of input should be added by 10 and when minus icon is press the value should be subtracted and displayed in the input.
How to achieve the calculation without storing the value in database and then running a data modify workflow. I want the calculation to be in page as simple and when done user will click on button bid to store value in db

thanks,

Just use a custom state to store the value…

For example:

  • Have a custom state of type number - you can set a static default value (i.e. 0), or set it its value on pageload if you need it to be dynamic.

  • Set the input’s initial content to be the custom state value

  • When the plus icon is clicked set the custom state value to be its current value +10

  • When the minus icon is clicked set the custom state value to be its current value -10

  • When the input’s value is changed, set the custom state value to be the input’s value, then rest the input.

1 Like

Thanks a lot for your answer, one question, i am using this thing (calculation) inside of a repeating group, so I have say 10 different inputs

to work with, and states of repeating group is only one, so ??

Just make sure the custom state is set on an element inside the cell - that way each instance of the element (inside each cell) will have its own value.

2 Likes

Thanks again for your support

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.