How to build a button that increments the value of a field by two percent of the current value

And decrement :wink: I think this would be practical because it is somewhat logarithmic, but I am struggling with the filter.

Give this a try:

<$edit-text field="value"/>
<$button>{{$:/core/images/chevron-up}}
   <$action-setfield value={{{ [{!!value}multiply[1.02]] }}}/>
</$button>
<$button>{{$:/core/images/chevron-down}}
   <$action-setfield value={{{ [{!!value}multiply[0.98]] }}}/>
</$button>

Enter an initial value into the input field (e.g., 1.00). Then press the up/down buttons to increment/decrement the current value.

enjoy,
-e

1 Like

Ahhh! Thank you. My Thoughts were too compicated.

\procedure setplus()
<$action-setfield $field="value" $value={{{ [<act>add<percent>] }}} />
\end

\procedure setminus()
<$action-setfield $field="value" $value={{{ [<act>subtract<percent>] }}} />
\end

<$let act={{!!value}} percent={{{ [<act>divide[100]multiply[2]] }}}>

|tc-table-no-border|k
| Value:|<$edit-text field="value" />|
| Modify:|<$button actions=<<setplus>> >+2%</$button><$button actions=<<setminus>> >-2%</$button>|

</$let>

Although Eric was quicker (as expected), here’s my try.
Sorry for being too late.

1 Like

Great, thank you!
your idea is as complicated as mine. But you succeded.

1 Like

My intention was also to show the different elements for this case, which can be easily combined in a later, advanced stage - like Erics solution is.