Very practical jquery Production Mall shopping cart automatically calculate the amount of form code, you can calculate a number of items of the total price.
function IsNumeric (stext) {var validchars = "0123456789.";
var isnumber=true;
var Char;
for (i = 0; i < stext.length && Isnumber = = true; i++) {Char = Stext.charat (i);
if (Validchars.indexof (Char) = =-1) {isnumber = false;
} return isnumber;
};
function Calcprodsubtotal () {var prodsubtotal = 0;
$ (". Row-total-input"). each (the function () {var valstring = $ (this). Val () 0;
Prodsubtotal + + parseint (valstring);
});
$ ("#product-subtotal"). Val (prodsubtotal);
};
function Calctotalpallets () {var totalpallets = 0;
$ (". Num-pallets-input"). each (the function () {var thisvalue = $ (this). Val ();
if ((IsNumeric (Thisvalue)) && (Thisvalue!= ')) {totalpallets + = parseint (Thisvalue);
};
}); $ ("#total-pallets-input"). Val (TotalpAllets);
};
function Calcshippingtotal () {var totalpallets = $ ("#total-pallets-input"). Val () 0;
var shippingrate = $ ("#shipping-rate"). Text () 0;
var shippingtotal = totalpallets * shippingrate;
$ ("#shipping-subtotal"). Val (shippingtotal);
};
function Calcordertotal () {var orderTotal = 0;
var productsubtotal = $ ("#product-subtotal"). Val () 0;
var shippingsubtotal = $ ("#shipping-subtotal"). Val () 0;
var orderTotal = parseint (productsubtotal) + parseint (shippingsubtotal);
var ordertotalnice = "$" + orderTotal;
$ ("#order-total"). Val (Ordertotalnice);
};
$ (function () {$ ('. Num-pallets-input '). blur (function () {var $this = $ (this);
var numpallets = $this. val (); var multiplier = $this. Parent (). Parent (). Find ("Td.price-per-pall
ET span "). text (); if ((IsNumeric (numpallets)) &&amP (Numpallets!= '))
{var rowtotal = numpallets * multiplier; $this. CSS ("Background-color", "White"). Parent (). Parent (). Find ("Td.row-t
Otal input "). Val (rowtotal);
else {$this. css ("Background-color", "#ffdcdc");
};
Calcprodsubtotal ();
Calctotalpallets ();
Calcshippingtotal ();
Calcordertotal ();
}); });