<script type="text/javascript" src="jquery.1.3.2.js"></script> <script type="text/javascript" src="jquery.math.1.0.js"></script> <script type="text/javascript"> $(function(){ // Set Tax Row $('table td.tax').multiply('.amount', 0.07); // Set totals $('table td.amount').subtotal().runningTotal(); // Stddev $('#stdDevExample').text('Stddev is: ' + $('span.data').stddev()); // Sum example $('#someSum').text('The sum is: ' + $('span.someSum').sum()); // Totals $('#taxTotal').text($('td.tax').sum()); $('#runningTotal').text($('td.runningTotal').sum()+' (meaningless)'); $('#total').text($('td.amount').sum()); $('#subtotal').text($('td.subtotal').sum()); // Average $('#invoiceAverage').text($('td.amount').average()); // Round Example $('#roundExample').text($('span.roundExample').round()); $('#roundExample2').text($('span.roundExample').round(3)); }); </script>
Note how the order of the Customer ID does not matter. Subtotals appear on the last row.
Anything with this color is generated by jQuery.math.
Check Number | Customer ID | Product ID | Tax | Invoice Amount | Running Total | Subtotal |
---|---|---|---|---|---|---|
1003 | MARK001 | CAMERA00356 | 345.45 | |||
1004 | MARK001 | CAMERA00356 | 345.45 | |||
53455 | PHIL045 | PS3000145 | 599.99 | |||
1005 | MARK001 | CAMERA00356 | 6945.45 | |||
1006 | MARK001 | CAMERA00356 | 345.45 | |||
53455 | PHIL045 | XBOX0360 | 299.99 | |||
4345 | SPEN010 | LAPTOP00432 | 2,003.04 | |||
4346 | SPEN010 | LAPTOP00532 | 1,203.04 | |||
Totals: | ||||||
Average: |
(number is extracted as-is via: $.math.settings.addExtractedNumbers = false; $.math.settings.extractNumbers = true;)
(numbers are extracted & added up via: $.math.settings.addExtractedNumbers = true; $.math.settings.extractNumbers = true;)
(decimals for all equations set via: $.math.settings.decimals = NNN;)
(decimals set via: $('selector').round(3);)