Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. $(function() {
  2.  
  3. function MakeFloat(sth) {
  4. return parseFloat(sth.text().replace(",", ".").replace(" ", ""));
  5. //return parseFloat(sth.html().replace(",",".").split(" ").join(""));
  6. }
  7.  
  8.  
  9. $('#table_dt').dataTable({
  10. "ordering": false,
  11. "pageLength": 100
  12. });
  13.  
  14. $('#btnGreaterSpirb').on('change', function(e) {
  15. $('.diff').each(function() {
  16. var diffValue = parseFloat($(this).text());
  17. console.log(diffValue);
  18. if (diffValue > 0) {
  19. $(this).closest('tr').toggleClass('warning');
  20. }
  21. });
  22.  
  23.  
  24. });
  25.  
  26. (function() {
  27. toSum = 0;
  28. diffSum = MakeFloat($('#diffSum'));
  29. $('tr#clickedRowToSum').on('click', function() {
  30. var amountInCell = MakeFloat($(this));
  31. if ($(this).hasClass('warning')) {
  32. toSum -= amountInCell;
  33. $('#clickedSum').text(toSum.toFixed(2));
  34. $(this).removeClass('warning');
  35. } else {
  36.  
  37. toSum += amountInCell;
  38. $('#clickedSum').text(toSum.toFixed(2));
  39. $(this).addClass('warning');
  40. if (diffSum == toSum) {
  41. alert("Suma wybranych dyspozycji równa jest brakującej kwocie");
  42. }
  43. }
  44. });
  45. })()
  46.  
  47.  
  48.  
  49.  
  50. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement