I have a table with repeat values. My issue is that i have two functions that i need to combine into one.
The first is a select all checkbox in the header of the table, which selects all other checkboxes on table rows below.
The second is that when a checkbox is selected, the value of another field (CheckedTotal) is added up and displayed elsewhere on the page.
When selecting the select all checkbox, it is not calculating the row values.
My functions:
function selectAllCheckboxes(obj,receivedInputID){
var inputCheckBox = document.getElementsByTagName("input");
for(var i=0; i<inputCheckBox.length; i++){
if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
inputCheckBox[i].checked = obj.checked;
}
}
};
function updateTotals() {
var sum = Array.prototype.reduce.call(document.querySelectorAll("input.check:checked"),(a,v) => a + parseFloat(v.dataset.totalIncludingGst), 0);
$('#checkedTotal').val(sum);
};
Aucun commentaire:
Enregistrer un commentaire