Hey I am trying to get input from a bunch of input boxes into an array in javascript
function lagreBilett(){
let inputElement = document.getElementsByName("bilett");
let bilett = {};
inputElement.forEach ((info) => {
bilett[info.id] = info.value;
info.value = '';
});
console.log(bilett);
let ut = "";
const biletter = [];
biletter.push(bilett);
for(let bilett of biletter){
ut += "Antall: " + bilett["antall"] + " Fornavn: " + bilett["fornavn"] + " Etternavn: " + bilett["etternavn"]
+ " Telefonnr: " + bilett["telefonnr"] + " Epost: " + bilett["epost"];
}
document.getElementById("resultat").innerHTML = ut;
}
But everytime i call upon the function, instead of creating a new object and putting it into the array with the other object, it just replaces it and creates a new one, this i think is because it has the same name, is their anyway to solve this?