Skip to content

Instantly share code, notes, and snippets.

@chalist
Created July 24, 2017 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chalist/4aec65f7dfb4bae653f20ab12cca3bb1 to your computer and use it in GitHub Desktop.
Save chalist/4aec65f7dfb4bae653f20ab12cca3bb1 to your computer and use it in GitHub Desktop.
ptp
<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