Código Javascript :
function calcularImporte(cant,pre,resultado)
{
with (document.forms["frmPedido"])
{
var totalResult = Number( cant.value ) * Number( pre.value );
resultado.value = totalResult;
calcularTotal();
}
}
function calcularTotal()
{
var imp_total = 0;
var mto_delivery = 10;
var mto_descto = 0;
var total = 0;
for (var i=0;i<document.getElementById("tbDetalle").rows.length;i++) {
//for (var j=0;j<5;j++) {
/* */
var imp = Number(document.getElementById("txtProdImporte_" + (i+1)).value);
imp_total = imp_total + imp;
//}
}
if (imp_total >0 && imp_total < 100) {
total = imp_total + mto_delivery;
}
if (imp_total >=100 && imp_total <= 300){
total = imp_total;
mto_descto = 0;
mto_delivery = 0;
}
if (imp_total > 300) {
mto_descto = 0.20 * imp_total;
mto_delivery = 0;
total = imp_total - mto_descto;
}
txtSubTotal.value = imp_total;
txtMtoDelivery.value = mto_delivery;
txtMtoDescto.value = redondeo2decimales(mto_descto);
txtTotal.value = total;
}
function redondeo2decimales(numero)
{
var original=parseFloat(numero);
var result=Math.round(original*100)/100 ;
return result;
}
Lo que hace es calcular los importes y total absoluto, lo malo que me corre en IE y tambien Chrome pero no es Firefox
Esta es la pagina donde lo estoy implementando : mirenlo en chrome y firefox
http://pedidosunique.com/
