html - How can group a form's checkboxes into an array in Node? -
i trying create form several checkboxes. want each checkbox share same name, , values of ones checked off submitted form. know can done php (see this question) can't figure out how node.js , express. here's modified version of html:
<label><input type="checkbox" name="section[]" value="1" />item name</label> <label><input type="checkbox" name="section[]" value="2" />item name</label> <label><input type="checkbox" name="section[]" value="3" />item name</label>
when handle post request, i've tried accessing values both req.param('section')
, req.param('section[]')
both return undefined.
if change line in app.js
:
app.use(bodyparser.urlencoded({ extended: false }));
to:
app.use(bodyparser.urlencoded({ extended: true }));
you should expecting req.param('section')
.
Comments
Post a Comment