Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($){
- function spin() {
- $(".foods").spinner({min: 0, max: 100, step: 1});
- $('.foods').addClass("enabled");
- }
- function updatePrice(){
- var Subtotal = 0;
- var tax = 0;
- var total = 0;
- $(".foods").each(function(){
- var price_text = $(this).closest("tr").find("td:nth-child(2)").text();
- var price = parseFloat(price_text.replace(/[^0-9\.]+/g,""));
- Subtotal = Subtotal + price * $(this).val();});
- Subtotal = Subtotal.toFixed(2);
- $("#Subtotal").val(Subtotal);
- tax = Subtotal * 0.13;
- tax = tax.toFixed(2);
- $("#Tax").val(tax);
- total = parseFloat(Subtotal) + parseFloat(tax);
- total = total.toFixed(2);
- $("#Total").val(total);
- }
- function disablePrice(){
- if ($("#Koobideh_Kabob").val() < 1 && ("#Koobideh_Kabob_extra").hasClass("enabled")) {
- $("#Koobideh_Kabob_extra").prop("readonly", true);
- $("#Koobideh_Kabob_extra").val(0).trigger("spinchange");
- $("#Koobideh_Kabob_extra").spinner("destroy");
- $("#Koobideh_Kabob_extra").removeClass("enabled");
- } else {
- $("#Koobideh_Kabob_extra").prop("readonly", false);
- $("#Koobideh_Kabob_extra").spinner({min: 0, max: 100, step: 1});
- $("#Koobideh_Kabob_extra").addClass("enabled");
- };
- if ($("#Joojeh_Kabob").val() < 1 && $("#Joojeh_Kabob_extra").hasClass("enabled")) {
- $("#Joojeh_Kabob_extra").prop("readonly", true);
- $("#Joojeh_Kabob_extra").val(0).trigger("spinchange");
- $("#Joojeh_Kabob_extra").spinner("destroy");
- $("#Joojeh_Kabob_extra").removeClass("enabled");
- } else {
- $("#Joojeh_Kabob_extra").prop("readonly", false);
- $("#Joojeh_Kabob_extra").spinner({min: 0, max: 100, step: 1});
- $("#Joojeh_Kabob_extra").addClass("enabled");
- };
- }
- $(document).ready(function() {
- spin();
- disablePrice();
- $(".foods").on("spinchange", updatePrice);
- $("#Koobideh_Kabob").on("spinchange", disablePrice);
- $("#Koobideh_Kabob").on("spinchange", updatePrice);
- $("#Joojeh_Kabob").on("spinchange", disablePrice);
- $("#Joojeh_Kabob").on("spinchange", updatePrice);
- });
- }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement