首页 > 解决方案 > Node/Express BodyParser 不从下拉菜单返回数据

问题描述

我正在尝试从注册表单创建一个 pug 文件,但下拉菜单不起作用。如何在正文解析器中包含我的下拉菜单?我认为它将与 json.stringify 一起使用。

注册.html

<div class="email">
    <span class="Req">*</span> <label for="Email Address"><b>Email
     Address:</b></label> <input type="text" name="Email Address:" id=
     "email">
     </div>
     <p>Have you ever paid for ideas?</p><input type="radio" name="paid"
            value="Yes" checked> Yes<br>
            <input type="radio" name="paid" value="No">No<br>
            <div class=menu>
            <p>Where do you usually shop for ideas?</p>
            <div class="custom-select">
              <select>
                <option value="0">
                  My Brain
                </option>
                <option value="1">
                  Other People
                </option>
                <option value="2">
                  The Internet
                </option>
              </select>
            </div>
          </div>
            <p>Have you ever purchased ideas?</p><input type="radio" name=
            "paid2" value="Yes" checked> Yes<br>
            <input type="radio" name="paid2" value="No">No<br>
            <p>How does using other peoples ideas compare to using/creating your own?<br> 

服务器.js

app.get('/', function(req, res, next){
  res.sendFile(express.static(__dirname+ "/bin/www/index.html"));
});

app.get('/SignUp', function(req, res, next){
  res.sendFile(express.static(__dirname+'/bin/www/Signup.html'));
});

app.get('/FAQ', function(req, res, next){
  res.sendFile(express.static(__dirname+'/bin/www/FAQ.html'));
});

// app.post method here for signUp
app.post('/Signup', function(req, res){
  res.end(JSON.stringify(req.body));
});" 

标签: htmlnode.jsexpress

解决方案


您需要name为 Select 元素添加一个属性

<select name="some-name">

推荐阅读