Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. function calculateTotalByMonth(month){
  2. var total=0;
  3. var num =0;
  4. var inputs = document.getElementsByName('check'+month);
  5.  
  6. for (var input of inputs) {
  7. num = parseInt(input.value);
  8. total+=num;
  9. }
  10.  
  11. total = total.toFixed(2);
  12. $('#totalmonth' + month).val(total);
  13. }
  14.  
  15. function calculateGrandTotal(){
  16. var total=0;
  17. var num =0;
  18. var inputs = document.getElementsByName('grand');
  19.  
  20. for (var input of inputs) {
  21. num = parseInt(input.value);
  22. total+=num;
  23. }
  24.  
  25. total = total.toFixed(2);
  26. $('#grandTotalBudget').val(total);
  27. }
  28.  
  29. else if (resp.type == C_CALCULATE_FORMULA){
  30. var data = resp.data.data_value + '';
  31. var array_value =data.split(',');
  32. var idx = 1 ;
  33. var arrIdx = 0;
  34. $('#table-budgeting-detail tr td').each(function() {
  35. var value = Number(array_value[arrIdx]);
  36. $('#budget_' +idx+'_'+resp.data.id_act).val(value.toFixed(2));
  37. idx ++;
  38. arrIdx ++;
  39. });
  40. addtotal(resp.data.id_act);
  41. calculateGrandTotal();
  42. for(i=1; i<=12; i++) {
  43. calculateTotalByMonth(i);
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement