Notum
1
Wappler 6.5.5 with NodeJS
I have a Repeat Form.

Code bellow returns value without problem:
formRepeatSplitLivingAnnuities.items[0].splitLivingAnnuitiesCurrentFundValue.value.replace(',', '', false).toNumber()
But code with SUM returns NaN:
formRepeatSplitLivingAnnuities.items.sum(splitLivingAnnuitiesCurrentFundValue.value.replace(',', '', false).toNumber())
Even this simple code returns NaN
formRepeatSplitLivingAnnuities.items.sum(splitLivingAnnuitiesCurrentFundValue.value)
What kind of values does this expression return?
splitLivingAnnuitiesCurrentFundValue.value
and what do you need the following expression for:
.replace(',', '', false)
The inputs return strings, not numbers, so probably you want to a conversion to number:
formRepeatSplitLivingAnnuities.items.sum(splitLivingAnnuitiesCurrentFundValue.value.toNumber())
Notum
3
{{splitLivingAnnuitiesCurrentFundValue.value}}
Return nothing even If I call it inside the repeat form.
formRepeatSplitLivingAnnuities.items.sum(splitLivingAnnuitiesCurrentFundValue.value.toNumber())
Returns NaN
Here is code for splitLivingAnnuitiesCurrentFundValue
<div class="input-group">
<span class="input-group-text bg-blue-70 text-white border-1 border-blue-70">R</span>
<input type="number" inputmode="numeric" class="validationwidthfix-small form-control text-end number-separator" id="splitLivingAnnuitiesCurrentFundValue" name=
Notum
4
@Teodor Did created a very simple page to test without anything un-needed:
<div class="container">
<div class="row">
<div class="col-12">
<h1>{{form1.formRepeat1.items.sum(text1.value.toNumber)}}</h1>
</div>
<div class="col-12">
<button id="btn1" class="btn" dmx-on:click="form1.formRepeat1.add()">Add</button>
<form id="form1">
<div is="dmx-form-repeat" id="formRepeat1" dmx-bind:items="1">
<div class="row">
<input id="text1" name="text1" type="number" class="form-control">
</div>
</div>
</form>
</div>
</div>
</div>
Please change the expression to:
formRepeatSplitLivingAnnuities.items.sum(`splitLivingAnnuitiesCurrentFundValue.value.toNumber()`)
it seems it is missing the ` around the expression in the sum.
2 Likes
Notum
6
By adding `` in to expression - test form started to work.
Checking on real example.
It must be:
<h1>{{form1.formRepeat1.items.sum(`text1.value.toNumber()`)}}</h1>
1 Like
Notum
8
Indeed - `` need to be added for the value you want to sum.
Thank you @Teodor