首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将数组从Textarea发布到mongoDB?

如何将数组从Textarea发布到mongoDB?
EN

Stack Overflow用户
提问于 2018-08-11 06:52:12
回答 1查看 644关注 0票数 3

我正在尝试发布一个序列号数组,但是一旦它被发布,所有添加到文本区域中的序列号都会作为单个字符串一起发布。

这是我的表格:

代码语言:javascript
复制
<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>

这是我的post请求

代码语言:javascript
复制
 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上的外观

enter image description here

我正在尝试创建序列号的输入,这样我们就可以跟踪保修时间。下面是我想要如何存储数据的一个示例。

代码语言:javascript
复制
{
productId: "laptops",
serial: [
11111,
22222, 
44444,
 ]

}

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51794917

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档