Node / Express BodyParser不从下拉菜单返回数据

时间:2019-05-03 21:52:40

标签: html node.js express

我正在尝试通过注册表单创建一个pug文件,并且下拉菜单无法正常工作。如何将下拉菜单包含在正文解析器中?我认为它将与json.stringify一起使用。

signup.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> 

server.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));
});" 

1 个答案:

答案 0 :(得分:0)

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

<select name="some-name">