javascript - 在复选框更改数据表中文本框的值
问题描述
我正在使用数据表。我正在对同一列中的所有数据求和
这是我的代码
{
title: "New Price", data: "price",
"render": function (data, type, row) {
return ' <input type="checkbox" value="' + data + '" >
<input type="number" id="newCost" class ="price-input" value="' + data + '" style="background-color:lightgoldenrodyellow;">';
}
function doSum5() {
var nodes = table7.column(3).nodes();
// get the value from each input field in each cell:
var total = table7.column(3).nodes()
// and then sum up the integer values:
.reduce(function (sum, node) {
return sum + parseFloat($(node).find('input').val());
}, 0);
// place the sum in the relevant footer cell:
var sum = parseFloat(total).toFixed(2)
$(table7.column(3).footer()).html(sum);
}
代码工作正常,现在我的问题是如何可能只选择那些字段作为选中复选框的总和。请指导我
解决方案
推荐阅读
- python - 子类化 Flask 可插拔视图以实现可扩展功能的最佳方式
- swift - 如何在帮助类中使用 DataSnapshot 对象?
- amazon-web-services - 无论登录如何,是否都有适用于 AWS 的通用 Cognito Id?
- r - 如何使用 R 删除多个文件的部分文件名
- unity3d - 从Android上的文件夹中迭代和读取文本文件
- php - GMail imap_fetchbody 不起作用
- selenium - 如何通过 Selenium WebDriver 从显示在“输入”标签而不是“选择”标签内的列表中选择一个选项
- javascript - Google Script - 通过电子邮件发送的图表更改日期格式
- azure - Azure 多租户应用无法访问
- cuda - Cuda:内核中的访问块和线程数?