Good evening, I am trying to create a simple app to calculate insurance rates. The 1st input is for the value of the item (whole numbers), the 2nd is for the insurance rates which will be in decimal numbers, once the numbers are entered it will do some additional math to get the charges and then post the total on a document on the web page. I can't seem to get the total to appear on the input field. Any help will be greatly appreciated being that this is my very 1st project.
Thank you, Edwin
total.addEventListener('click',() => {
const rte1 = parseFloat(document.getElementById('val$').value);
const rte2 = parseFloat(document.getElementById('valRate').value);
const surCharge = rte1 * rte2;
const ept = surCharge * .036;
const totalCharge = surCharge + ept;
document.getElementById('price').innerHTML = totalCharge;
});
<p class="coll mt-4 text-primary">Enter Value:</p>
<input id="val$" type="text" name="rate1">
<p class="coll mt-4 text-primary">Enter Insurance Rate:</p>
<input id="valRate" type="text" name="rate2">
<!-- Calculate Button -->
<button onclick="total" type="button" class="btn btn-primary active d-block mx-auto mt-4">Calculate</button>
<p class="coll mt-5 text-primary">Total charges including IPT:</p>
<input id="price" type="text">