How do I sum grouped values from a table? For example I will sum the name?
this values :
2.997,
7.497
return : result!
I already have a function which delivers the whole sum this works fine. But I have don't a clue how to solve this problem ![enter image description here][1]
here is my function for the whole sum!
function calculateSum() {
var sum = 0;
$(".overviewTaxes").each(function() {
var value = $(this).text();
// add only if the value is number
if(!isNaN(value) && value.length != 0) {
sum += parseFloat(value);
}
});
$( ".globalTaxSum" ).html(sum);
}
<tbody>
<?php foreach ($overviews as $overview): ?>
<tr>
<td >
<?php echo $overview["forename"] . " " . $overview["surname"]; ?>
</td>
<td>
<?php echo $overview["article"]; ?>
</td>
<td>
<?php echo $overview["articleprice"]; ?>
</td>
<td class="overviewTaxes">
<?php
$ps = $overview["articleprice"] * 0.3; //flat rate
echo round($ps, 3) ;
?><br/>
</td>
</tr>
<?php endforeach; ?>
</tbody>
Thanks for help.
Best regards
Marc Kevin