I created a function to be called to update a total amount:
It gets all inputs with a specific class, and performs the calc, and then sets a value in the dmx world.
function findTotal() {
var arr = document.getElementsByClassName('quote_detail_amount');
var tot = 0;
for (var i = 0; i < arr.length; i++) {
if (parseFloat(arr[i].value))
tot += parseFloat(arr[i].value);
}
dmx.parse("content.quote_total_amount.setValue(" + tot + ")");
}
The following is the input inside the repat, that I want to use in the function calc, so I add a class to it and add the onupdated attribute:
<input id="inp_quote_detail_amount" name="" type="tel" class="form-control form-control-sm quote_detail_amount" dmx-bind:value="(inp_quote_detail_cost.value.toNumber() + inp_quote_detail_margin.value.toNumber())" readonly="true" disabled="true" onupdated="findTotal()">
And then I display the total using the dmx var:
<p class=" mb-0" dmx-text="quote_total_amount.value.formatCurrency('$', '.', ',', 2)"></p>