NodeJS,分配名称/获取Jadecheckbox的值

我从Mongo数据库的表单中填充表格。 我希望用户能够select一个或多个checkbox,然后确定从表格中select了哪些项目。 问题的一个部分是,我不知道如何命名checkbox,因为它们是dynamic创build的。 我也不知道如何阅读checkbox属性。

我正在使用ExpressJS和翡翠。 我可以填充表没有问题,但不知道如何沟通哪些项目被选中。

这是我的玉

h1 index view form (method='post', action='/customers/check') fieldset legend Add a Customer div.clearfix -if(docs.length) table(style="border-left:1px solid black") tr th First Name th Last Name th "Hidden" each first in docs tr td #{first.first} td #{first.surname} td #{first.group} td div.input input(type="checkbox", name=(#{first.box}), unchecked= (true===true ? "checked" : "")).checkbox div.actions input(type='submit', value='Save', class='btn primary') button(type='reset', class='btn') Cancel 

我的Mongo数据库有四个属性(第一,姓,组和我添加框试图解决这个问题)在大图中我正在做的是采取一个stringinput,然后呈现一个视图与这张表,我想存储stringinput和任何元素从表中select到另一个mongoDB有两个属性(string和复杂的对象)请saveee meeee !!!谢谢

啊,它一直在解决问题

  h1 index view form(method='post', action='/customers/check') fieldset legend Add a Customer div.clearfix -if(docs.length) table(style="border-left:1px solid black") tr th First Name th Last Name th "Hidden" each first in docs tr td #{first.first} td #{first.surname} td #{first.group} td div(data-role='fieldcontain') fieldset(data-type='vertical', data-role='controlgroup') label(for='showpass') show password input(id='showpass',type='checkbox', name='#{first.id}') div.actions input(type='submit', value='Save', class='btn primary') button(type='reset', class='btn') Cancel 

和我的服务器端我把检查值到一个名为“ARR”的数组,在这里

  app.post('/customers/check', function(req, res) { console.log(req.body); var locks = req.body; var arr = Object.keys(locks); console.log(arr); res.redirect('/customers') });