Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. jQuery(document).ready(function () {
  2. function iDoMathsGood() {
  3. $('.amount').map(function () {
  4. // get all of the elements we'll need to manipulate
  5. var row = $(this).parent().parent();
  6. var originalTtl = row.find('.price');
  7. var adjusted = row.find('.adj_ct');
  8.  
  9. // get the numbers we'll need and do some math
  10. var cts = Number(row.find('.weight').html());
  11. var origPPCT = Number(row.find('.org_ct').html()) * 1000;
  12. var markupPrct = Number($('#markup').val()) / 100;
  13. var markedupCost = (origPPCT * markupPrct) + origPPCT;
  14.  
  15. // do a little more math them set the results
  16. adjusted.html((markedupCost / 1000).toFixed(2));
  17. originalTtl.html(((origPPCT * cts) / 1000).toFixed(2));
  18. return $(this).html(((markedupCost * cts) / 1000).toFixed(2));
  19. });
  20. }
  21. iDoMathsGood();
  22. $('#markup').keyup(function () {
  23. iDoMathsGood();
  24. });
  25.  
  26.  
  27.  
  28.  
  29.  
  30. //button to reset input values
  31. $("#btn").click(function(){
  32. /* Single line Reset function executes on click of Reset Button */
  33. $("#form")[0].reset();
  34.  
  35. });
  36.  
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement