Created
July 24, 2017 23:07
-
-
Save chalist/4aec65f7dfb4bae653f20ab12cca3bb1 to your computer and use it in GitHub Desktop.
ptp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
jQuery(function () { | |
jQuery('body').on('keydown keyup change', '.quantity .input-text.qty', function () { | |
var t = jQuery(this); | |
var max = parseInt(t.attr('max')); | |
var v = parseInt(t.val()); | |
if (v > max) { | |
t.val(max); | |
return false; | |
} | |
}); | |
function calc_metraj() { | |
try { | |
var metraj = jQuery('#id_metraj').val(); | |
var base_count = jQuery('#ch_amount').val(); | |
if (metraj && base_count) { | |
var res = metraj * base_count; | |
var r = Math.ceil(metraj * base_count); | |
jQuery('#amount_count').text(r); | |
} else { | |
jQuery('#amount_count').text(0); | |
} | |
} catch (err) { | |
} | |
} | |
calc_metraj(); | |
jQuery('body').on('keydown keyup change', '#id_metraj', function () { | |
calc_metraj(); | |
}); | |
jQuery('body').on('click', '#add_to_cart_req', function () { | |
var t = jQuery(this); | |
jQuery('.quantity .input-text.qty').val(jQuery("#amount_count").text()); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment