I’m trying to get a numerical user input to display elsewhere on the page through an id whenever the input box is changed, but it just won’t work. Here’s what I’ve been using
function updateTotalCashPaid() {
var x;
var cashInput = document.getElementById("cashPaid").value;
x = cashInput;
document.getElementbyId("totalCashPaid").innerHTML = x;
}
<p style="padding-left:10%"><input type="Number" id="cashPaid" name="cashPaid" step=".01" min="0" onchange="updateTotalCashPaid()"></p>
<p id="totalCashPaid" style="display: inline; ">replace with User Input</p>
Does anyone see what I’m doing wrong?
I see a simply typo. Instead of
getElementById, you havegetElementbyIdatdocument.getElementbyId("totalCashPaid").innerHTML = x;