Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var pref = ".valrep_condo_comp";
  2. var area = "_area-inputEx-fieldWrapper";
  3. var ask_price = "_base_price-inputEx-fieldWrapper";
  4. var price = "_price_value-inputEx-fieldWrapper";
  5. var discount_rate = "_discount_rate-inputEx-fieldWrapper";
  6. var discounted_price = "_discounts-inputEx-fieldWrapper";
  7. var index_price = "_selling_price-inputEx-fieldWrapper";
  8.  
  9. for(var i = 1; i < 6; i++) {
  10. var this_area = $j(pref + i + area);
  11. var this_ask_price = $j(pref + i + ask_price);
  12. var this_price = $j(pref + i + price);
  13. var this_discount_rate = $j(pref + i + discount_rate);
  14. var this_discounted_price = $j(pref + i + discounted_price);
  15. var this_index_price = $j(pref + i + index_price);
  16. $j(pref + i + area).on("keydown keyup change paste", function() {
  17. alert(this_area.attr('class'));
  18. alert(this_ask_price.val());
  19. this_area.find("input[type='text']).val(getPrice(this_ask_price,this_area));
  20. this_discounted_price.find("input[type='text']").val(getDiscount(this_price,this_discount_rate));
  21. this_index_price.find("input[type='text']").val(getIndexPrice(this_price,this_discounted_price));
  22. });
  23. }
  24.  
  25. function getPrice(x,y) {
  26. if($j(x + " input[type='text']").val().replace('PhP', '') === 0) {
  27. return 0;
  28. }
  29. else {
  30. return $j(x + " input[type='text']").val().replace('PhP', '').replace(/[^0-9a-zA-Z.]/g, '') / $j(y + " input[type='text']").val();
  31. }
  32. }
  33.  
  34. function getDiscount(x,y) {
  35. if($j(x + " input[type='text']").val().replace('PhP', '') === 0) {
  36. return 0;
  37. }
  38. else {
  39. return $j(x + " input[type='text']").val().replace('PhP', '').replace(/[^0-9a-zA-Z.]/g, '') * ($j(y + " input[type='text']").val() / 100);
  40. }
  41. }
  42.  
  43. function getIndexPrice(x,y) {
  44. if($j(x + " input[type='text']").val().replace('PhP', '') === 0) {
  45. return 0;
  46. }
  47. else {
  48. return parseFloat($j(x + " input[type='text']").val().replace('PhP', '').replace(/[^0-9a-zA-Z.]/g, '')) + parseFloat($j(y + " input[type='text']").val());
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement