1/* 2 * Handles calculation of the cart total based on selected fields and updates the total field. 3 */ 4 5 6jQuery(document).ready(function () { 7 //calculate the cart total for each form based on defaults at page load 8 jQuery('form.dygform').each(function () { 9 dygformCalculateCart(jQuery(this).data('form-name')); 10 }); 11 12 //calculate the cart total for a specific form when an element is changed 13 jQuery('.dygform-cart-value, .dygform-cart-qty').change(function () { 14 dygformCalculateCart(jQuery(this).closest('form').data('form-name')); 15 }); 16}); 17 18function dygformCalculateCart(form) { 19 var total = 0.00; 20 jQuery(`.dygform-${form} .dygform-cart-value:checked`).each(function () { 21 total += parseFloat(jQuery(this).val()); 22 }); 23 jQuery(`.dygform-${form} .dygform-cart-value[type='number']:visible`).each(function () { 24 total += parseFloat(jQuery(this).val()); 25 }); 26 jQuery(`.dygform-${form} .dygform-cart-qty:visible`).each(function () { 27 total += parseFloat(jQuery(this).val() * parseFloat(jQuery(this).data('dygform-cart-unit'))); 28 }); 29 jQuery(`.dygform-${form} .dygform-cart-total`).val("$" + total.toFixed(2)); 30 var gst = total / 11; 31 jQuery(`.dygform-${form} .dygform-cart-gst`).val("inc $" + gst.toFixed(2) + ' gst'); 32}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.