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

391
Visualizações
How to get dynamic form value after click submit in Javascript?

I have a dynamic form data which is loaded from backend. If there are static form, I can get value by document.getElementById("xxx"). However, if there are dynamic form which is unknown id, how can I get the value ? I would like to have these format to submit on it

    "answers" :[
    {
        "questionId" : 1002,
        "response" : "Yes"
    },{
        "questionId" : 1001,
        "response" : "No"
    }
]

Here is stackblitz link

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

When you are looping over the form, you can generate class name or id from data fetched from backend, or you can construct new one.

about 4 years ago · Juan Pablo Isaza Relatório

0

  1. Put your form fields inside a form tag (including the submit button).

  2. Give a class to the form e.g. custom-form

  3. Add a submit listener on the .custom-form selector.

    $('.custom-form').on('submit', function formSubmitHandler(event) {  
        // add logic here 
    });
    
  4. Inside the submit handler, get the input fields by doing something like this:

    const formInputs = $(this).find("input");  //this will retrieve all the input tags inside the form.
    

    You can now loop through them and perform your desired operation.

about 4 years ago · Juan Pablo Isaza Relatório
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