Javascript 第二个表单提交覆盖node.js中的mongo数据库
我有两张表格,我一次点击一个按钮就可以得到。 问题是,只有第二个表单输入被写入数据库。 就像是第二种形式。我试图更改submit()调用的顺序,并且总是将第二个调用表单的输入写入数据库。 有什么建议吗 保存方法:Javascript 第二个表单提交覆盖node.js中的mongo数据库,javascript,html,node.js,mongodb,express,Javascript,Html,Node.js,Mongodb,Express,我有两张表格,我一次点击一个按钮就可以得到。 问题是,只有第二个表单输入被写入数据库。 就像是第二种形式。我试图更改submit()调用的顺序,并且总是将第二个调用表单的输入写入数据库。 有什么建议吗 保存方法: app.post('/saveInScopeStatuses', function (req, res) { var db = req.db; var scopes = req.body.scope; var collection = db.get('scope
app.post('/saveInScopeStatuses', function (req, res) {
var db = req.db;
var scopes = req.body.scope;
var collection = db.get('scopestatuses');
var total = scopes.length;
for (var i = 0; i<total; i++){
var scope = scopes.pop();
collection.update({"status": {
$eq: scope}
}, {
$set: {
inscope: true
}
},
{upsert: true});
}
});
app.post('/saveOutScopeStatuses', function (req, res) {
var db = req.db;
var scopes = req.body.scope;
var collection = db.get('scopestatuses');
var total = scopes.length;
for (var i = 0; i<total; i++){
var scope = scopes.pop();
collection.update({"status": {
$eq: scope}
}, {
$set: {
inscope: false
}
},
{upsert: true});
}
});
app.post('/saveInscopeStatus',函数(req,res){
var db=请求db;
变量范围=req.body.scope;
var collection=db.get('scopestatuses');
var total=scopes.length;
对于(var i=0;i