Advertisement
Danny_Berova

1.FormAcc

Nov 19th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. function acceptance() {
  2. let company = $('input').eq(0);
  3. let prodName = $('input').eq(1);
  4. let quantity = $('input').eq(2);
  5. let scrape = $('input').eq(3);
  6. let allPresent = company.val().trim() && prodName.val().trim() && quantity.val().trim() && scrape.val().trim();
  7.  
  8. if(allPresent && typeof +quantity.val() === "number" && typeof +scrape.val() === "number") {
  9. if(+quantity.val() - +scrape.val() > 0) {
  10.  
  11. let ware = $('#warehouse');
  12. let prodInfo = $('<div>');
  13. let p = $('<p>').text(`[${company.val()}] ${prodName.val()} - ${+quantity.val() - +scrape.val()} pieces`);
  14. let button = $('<button>')
  15. .attr('type', 'button')
  16. .text('Out of Stock')
  17. .on('click', function (ev) {
  18. ev.target.parentNode.remove();
  19. });
  20. prodInfo.append(p, button);
  21. ware.append(prodInfo);
  22. }
  23. }
  24.  
  25. company.val('');
  26. prodName.val('');
  27. quantity.val('');
  28. scrape.val('');
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement