Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a form on Handlebar. It generates dynamic textboxes and dropdowns based on which type of form it is. Now I have to submit this form to a nodejs route. There i ahve req.body. We generaly process form field by like req.body.name, req.body.class. I dnt know how to handle dynamic fields in req.body._dynamicfieldname__


The above form control is not dynamic so i can easily process req.body.pin

Now

In this case how can i get the req.body.dynamicfieldname inside nodejs route


routes.post('/applyforadmission', async(req,res)=>{
console.log(req.body);
let dy = req.body.pin;

// how to access req.body.dynamicfieldname (which is dynamically generated on frontend)
res.render('admission');
});

What I have tried:

I tried to set a separate parameter which holds all dynamic names and value. But is there any proper way to do it
Posted

1 solution

I think you can iterate over the body if it is JSON using the forEach or map that is built-in JS.
 
Share this answer
 
Comments
CHill60 26-Jan-21 12:12pm    
I think a little more detail is required

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900