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

178
Visualizações
can't diasble autorefresh o the page

i have a form where user should make new inputs

now user can make new input BUT once only


index.html

<form id="MyForm">
            <input type="text" class="Line" id="Line0">
</form>

index.js

MyForm.addEventListener('submit', {
    handleEvent(event) {//make new line
        event.preventDefault();
        let myForm = document.getElementById("MyForm");
        myForm.insertAdjacentHTML("beforeend", "<input type='text' class='Line'id='line1'>")
    }
})

i have tried :

function new_line(index, event) {
    //change all indexes before this object
    let FormArray = Array.from(MyForm)
    MyForm.insertAdjacentHTML("beforeend", "<input type='text' class='Line' id='Line" + FormArray.length + " onsubmit='return new_line(" + FormArray.length + ")'>")
    event.preventDefault();
}

and

function new_line(index) {
    //change all indexes before this object
    let FormArray = Array.from(MyForm)
    MyForm.insertAdjacentHTML("beforeend", "<input type='text' class='Line' id='Line" + FormArray.length + " onsubmit='return new_line(" + FormArray.length + ")'>")
    return false;
}

but both of this functions update the page before i understand do they work or not

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