Advertisement
freddy0512

keyup

Apr 23rd, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. $(document).on('keyup', '.quantity', function() {
  2. var el = $(this);
  3. var root = el.parents('tr');
  4. var currentName = root.find('.kodebarang').val();
  5. var currentStock = root.find('.stock').val();
  6. var totalCurrentQty = 0;
  7. $(".kodebarang").each(function() {
  8. var currentScanName = $(this);
  9. var currentScanRoot = currentScanName.parents('tr');
  10. var currentScanNameValue = currentScanName.val();
  11. if (currentScanNameValue == currentName) {
  12. var tmpQtyValue = currentScanRoot.find('.quantity').val();
  13. totalCurrentQty = totalCurrentQty + parseInt(tmpQtyValue);
  14. }
  15. })
  16. if (totalCurrentQty > currentStock) {
  17. $(this).css("background-color", "red");
  18. $('button').prop('disabled', true);
  19. }
  20. else
  21. {
  22. $(this).css("background-color", "#fff");
  23. $('button').prop('disabled', false);
  24. }
  25. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement