[英]Post required `<td>` only in Express.js
{{#if results}}
<form method="post">
<div class="table">
<table border="1" style="width:100%;background-color:white;color:black;padding-top:10px;">
<tr>
<tr>
<th>RegNo</th>
<th>Name</th>
<th>Department</th>
<th>Mail ID</th>
<th>Phone No</th>
<th></th>
<th></th>
</tr>
{{#each results}}
<tr>
<td name="id" > {{ID}}</td>
<td>{{name}}</td>
<td>{{department_name}}</td>
<td name="email" > {{email_id}} </td>
<td>{{phone_num}}</td>
<td><button style="border:1;" class="button" formaction="block">Block</button></td>
<td><button style="border:1;" class="button" formaction="remove">Remove</button></td>
</tr>
</tr>
</form>
{{/each}}
</table>
{{else}}
<div> No User exists</div>
{{/if}}
结果包含长度为n的数据。 当我单击该块时,我需要从<td>
获得两个数据,因此在服务器中:
router.post('/block', ensureAutheticated, (req, res) => {
console.log(req.body);
var regno = req.body.id;
var email = req.body.email;
console.log(regno, email);
});
但这是行不通的。 <td>
不能在其中放置名称。 这个怎么做? 单击该块将仅向服务器返回该行的数据或表数据。
最简单的方法是添加两个隐藏的输入,因为TD无法通过表单传递值
<input type="hidden" name="id" value="{{ID}}" />
<input type="hidden" name="email" value="{{email_id}}" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.