Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var pref = ".valrep_condo_comp";
- var area = "_area-inputEx-fieldWrapper";
- var ask_price = "_base_price-inputEx-fieldWrapper";
- var price = "_price_value-inputEx-fieldWrapper";
- var discount_rate = "_discount_rate-inputEx-fieldWrapper";
- var discounted_price = "_discounts-inputEx-fieldWrapper";
- var index_price = "_selling_price-inputEx-fieldWrapper";
- for(var i = 1; i < 6; i++) {
- var this_area = $j(pref + i + area);
- var this_ask_price = $j(pref + i + ask_price);
- var this_price = $j(pref + i + price);
- var this_discount_rate = $j(pref + i + discount_rate);
- var this_discounted_price = $j(pref + i + discounted_price);
- var this_index_price = $j(pref + i + index_price);
- $j(pref + i + area).on("keydown keyup change paste", function() {
- alert(this_area.attr('class'));
- alert(this_ask_price.val());
- this_area.find("input[type='text']).val(getPrice(this_ask_price,this_area));
- this_discounted_price.find("input[type='text']").val(getDiscount(this_price,this_discount_rate));
- this_index_price.find("input[type='text']").val(getIndexPrice(this_price,this_discounted_price));
- });
- }
- function getPrice(x,y) {
- if($j(x + " input[type='text']").val().replace('PhP', '') === 0) {
- return 0;
- }
- else {
- return $j(x + " input[type='text']").val().replace('PhP', '').replace(/[^0-9a-zA-Z.]/g, '') / $j(y + " input[type='text']").val();
- }
- }
- function getDiscount(x,y) {
- if($j(x + " input[type='text']").val().replace('PhP', '') === 0) {
- return 0;
- }
- else {
- return $j(x + " input[type='text']").val().replace('PhP', '').replace(/[^0-9a-zA-Z.]/g, '') * ($j(y + " input[type='text']").val() / 100);
- }
- }
- function getIndexPrice(x,y) {
- if($j(x + " input[type='text']").val().replace('PhP', '') === 0) {
- return 0;
- }
- else {
- return parseFloat($j(x + " input[type='text']").val().replace('PhP', '').replace(/[^0-9a-zA-Z.]/g, '')) + parseFloat($j(y + " input[type='text']").val());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement