我使用Node + JS + Express + Jade將網頁值插入到Mongo DB中。 我需要插入True或False,取決於複選框是否啓用。閱讀複選框的值Node + JS + Express + Jade
在我router.js我有以下幾點:
app.get('/notification', function(req, res) {
res.render('notification', { title: 'Nueva notificacion', notifications : NT });
});
app.post('/notification', function(req, res){
console.log('Adding new notification');
AM.addNewNotification({
name : req.param('name'),
notification : req.param('notification'),
active : req.param('active')
}, function(e){
if (e){
res.send(e, 400);
} else{
res.send('ok', 200);
}
});
});
在我看來,我有以下幾點:
.controls
label#active-me.checkbox Active
input(type="checkbox", name="active", id="active",checked='checked')
但我不能將它插入,貌似值不採取。 只插入名稱和通知值(文本)。
{ "name" : "Goodbye world", "notification" : "Short Message Service", "_id" : ObjectId("5298f603bd07b80376000005") }
有什麼建議嗎?
謝謝