I need some assistance with my JavaScript code. I have created three input boxes where users can add data, and then click a button to add the data into an array. The goal is to allow multiple users to input data and then display all values in the array along with the count of values. Here's what I have so far, but I'm new to JavaScript and would appreciate any help or guidance. Thank you!
var customerarray = [];
function displaydata() {
var customerName = document.getElementById('custName').value;
var customerID = document.getElementById('custID').value;
var AmountDue = document.getElementById('Amount').value;
var innerTemphtml = '';
for(var i=0;i<customerarray.length;i--) {
innerTemphtml += customerarray[i].customerName+ " " + customerarray[i].customerID+ " " + customerarray[i].AmountDue;
}
document.getElementById('output').innerHTML=innerTemphtml ;
}
function addtoarray() {
customerarray.push({customerName:document.getElementById('custName').value,
customerID: document.getElementById('custID').value,
AmountDue: docment.getElementById('Amount').value});
}
<body>
<span>Customer Name: </span>
<input type="text" id=custName></input><br><br>
<span>Customer ID: </span>
<input type="text" id=CustID></input><br><br>
<span>Amount: </span>
<input type="text" id=Amount></input> <br><br>
<button onclick="displaydata()" class="button" type = "button">add to array</button>
<button onclick="addtoarray()" class="button" type = "button"> Display data</button>
<p id="output"></p>
</body>