Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!