如何从contenteditable from node.js更新值
我正在尝试更新html中的值,这些值会立即影响计算新值并显示在网页上。如何从contenteditable from node.js更新值,node.js,express,ejs,Node.js,Express,Ejs,我正在尝试更新html中的值,这些值会立即影响计算新值并显示在网页上。 下面是我的.ejs文件: <tr> <% bodies.forEach(function(body){ %> <% if(typeof body.qty !== 'undefined') { %> <th contenteditable="true"><%= body.qty %></th&
下面是我的
.ejs
文件:
<tr>
<% bodies.forEach(function(body){ %>
<% if(typeof body.qty !== 'undefined') { %>
<th contenteditable="true"><%= body.qty %></th>
<% } %>
<% if(typeof body.total !== 'undefined') { %>
<th><%= body.total %></th>
<% } %>
<% } %>
<% }) %>
</tr>
<form action="/" method="post">
<input type="text">
<button type="submit">Find</button>
</form>
app.post("/", function(req, res){
if(isNaN(req.body.qty)) {
qty = 1;
} else{
qty = req.body.qty;
}
total = qty * price;
var bodies = [{qty: qty, total: total}]
res.render("list", {bodies:bodies});
});
问题:
如果用户更改了数量字段,我如何修改代码以反映更改。
假设数量设置为1,那么总数为50(价格设置为50)。然后,如果用户从web将数量更改为50,则我预期为250 它是如何知道变化的<我应该把eventlistener给谁 解决它 下面是该网页的一个示例。