html - 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));
});"
解决方案
您需要name
为 Select 元素添加一个属性
<select name="some-name">
推荐阅读
- python - 如何在Django的footer.html中渲染常见的东西
- c++ - 阅读我正在阅读的文件的下一行
- c - TM4C1294XL 以二进制模式闪烁 LED
- javascript - 通过利用 _.map 和 ._groupBy 用 lodash 重构数组
- python - 从文件夹 Python 中获取最后一个文件
- javascript - 从 ajax 向 Web 服务器发送连续请求时页面停止响应并冻结
- python - 神经网络中稀疏矩阵的使用
- react-native - 如何将颜色应用于 lottie-react-native 图标
- python - Flask 应用程序导入在第二次路由时不起作用
- android - 为 React Native 创建自定义 SDK