I'm using http://autonumeric.org/ or https://github.com/autoNumeric/autoNumeric/blob/master/README.md
How to fix
When I use JS function to calculate the sum total appear, but not as formatted AutoNumeric as I want it to be
When mouse hover the calculated field, it disappears
var taxRate = 0.10
function calculateAmount() {
var elemsAmount = document.getElementsByName("tAmount")
var total = 0
elemsAmount.forEach(function(e){
total += Number(e.value.replace(',',''))
})
document.getElementById("total").value = total
document.getElementById("tax").value = total*taxRate
document.getElementById("finalTotal").value = total+total*taxRate
}
document.getElementById("tableBox").addEventListener("change",calculateAmount)
new AutoNumeric.multiple('[contenteditable="true"]', 'dotDecimalCharCommaSeparator')
<script src="https://unpkg.com/autonumeric" type="text/javascript"></script>
<div id="tableBox">
<div name="tableRow">
<div class="col s3">
<div class="input-field">
<input type="text" name="tAmount" contenteditable="true">
<label>input</label>
</div>
</div>
</div> <!-- name tableRow -->
<div name="tableRow">
<div class="col s3">
<div class="input-field">
<input type="text" name="tAmount" contenteditable="true">
<label>input</label>
</div>
</div>
</div> <!-- name tableRow -->
</div> <!-- id tableBox -->
Auto JS Calculation fields
<div class="input-field">
<input type="text" id="total" contenteditable="true">
<label for="total">Total</label>
</div>
<div class="input-field">
<input type="text" id="tax" contenteditable="true">
<label for="tax">Tax</label>
</div>
<div class="input-field">
<input type="text" id="finalTotal" contenteditable="true">
<label for="finalTotal">Final Total</label>
</div>
Expect output #,###.##<br>
Also the problem is when mouse hover on the Calculation field, it disappears
Thank you in advance