Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda