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

387
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
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