in a php page, I have the following Javascript code:
<script>
let items = 0;
function addItem() {
items++;
let html = "<tr>";
html += "<td>" + items + "</td>";
html += "<td><input type='text' class='form-control' name='itemName[]'></td>";
html += "<td><input type='text' class='form-control' name='itemCompany[]'></td>";
html += "<td style='width:60px;'><input type='text' class='form-control itemQuantity' id='itemQuantity' name='itemQuantity[]'></td>";
html += "<td style='width:100px;'><input type='text' class='form-control itemPrice' id='itemPrice' name='itemPrice[]'></td>";
html += "<td style='width:100px;'><input type='text' class='form-control' id='itemAdvance' name='itemAdvance[]'></td>";
html += "<td style='width:100px;'><input type='text' class='form-control' id='itemDiscount' name='itemDiscount[]'></td>";
html += "<td style='width:100px;'><input type='text' class='form-control' name='itemRounding[]'></td>";
html += "<td><input type='text' class='form-control' name='itemNote[]'></td>";
html += "<td style='text-align:center'><button type='button' class='btn btn-danger' onclick='deleteRow(this);'>Delete</button></td>";
html += "<td><input type='text' readonly name='result' id='result'></td>";
html += "</tr>";
let row = document.getElementById("tbody").insertRow();
row.innerHTML = html;
}
function deleteRow(button) {
items--
button.parentElement.parentElement.remove();
}
</script>
I want to display in the input field with id=”result”, a preview of the calculation between the fields itemQuantity, itemPrice, itemAdvance and itemDiscount. I have tried in all ways but the result is not displayed in any case.
I tried to get the result but it doesn’t print