【发布时间】:2019-01-18 13:34:45
【问题描述】:
我正在尝试发布一个序列号数组,但是一旦发布,在 textarea 中添加的所有序列号都会作为单个字符串一起发布。
这是我的表格:
<form class="" id="serialsForm" action="/serialsnew" method="post">
<h5 style="text-align:center">Procesar RMA</h5>
<input placeholder="Product ID"class="input1" type="text"
name="productId" value="">
<textarea id="textAreaSerial" class="newSeriales" placeholder="#
Seriales"name="serial[]" rows="3" cols="80" ng-trim="false"> .
</textarea>
<button type="submit" value="send" class="btn btn-primary
buttonNewRma" data-toggle="modal" id="submit">
submit
</button>
</form>
这是我的发帖请求
app.post("/serialsnew", function(req, res){
var productId = req.body.productId;
var serialNum = req.body.serial;
Seriales.create({
product: productId,
seriales: serialNum,
}, function(err, serial){
if(err){
console.log("we coulndt add the serial numbers")
} else{
console.log("we just added a patch of serials")
}
})
res.json(req.body);
// res.redirect("/serialsnew")
})
这就是我的数组在 res.json 上的样子
我正在尝试创建序列号输入,以便我们跟踪保修时间。下面是我希望如何存储数据的示例。
{
productId: "laptops",
serial: [
11111,
22222,
44444,
]
}
【问题讨论】:
-
请提供有关所需输出的信息。此外,您不必附加图像......只需输入对象输出以及您希望数据看起来像什么。
-
你好@Akrion 我刚刚编辑了帖子,我添加了我希望如何将我的参数存储在数据库中,我想在文本区域中传递几组数字,然后将它们存储为连载中的数组。我希望这会有所帮助。非常感谢
标签: javascript jquery node.js express post