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

385
Views
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 answers
Answer question

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 Report

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 Report
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!