Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
Listing inputs from a form into an array - JAVASCRIPT

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?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda