ENTIENDO QUE ESTE SCRIPT ME ESTA DANDO PROBLEMAS CON LOS DECIMALES A LA HORA DE TRABAJAR CON EUROS, ALGUIEN ME PODRIA DECIR QUE DEBO CAMBIAR Y QUE PARTE PUEDO ELIMINAR TENIENDO EN CUENTA QUE NO APLICO TASAS Y EL PRECIO ES CON IVA INCLUIDO.
GRACIAS
<SCRIPT LANGUAGE="JavaScript">
function alterError(value) {
if (value<=0.99) {
newPounds = '0';
} else {
newPounds = parseInt(value);
}
newPence = parseInt((value+.0008 - newPounds)* 100);
if (eval(newPence) <= 9) newPence='0'+newPence;
newString = newPounds + '.' + newPence;
return (newString);
}
function showItems() {
index = document.cookie.indexOf("TheBasket");
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
fulllist = document.cookie.substring(countbegin, countend);
totprice = 0;
document.writeln('<form><table border="1" cellspacing="0" width="640" bgcolor="#FFFF80" bordercolor="#804040" class="td">');
document.writeln('<TR><TD width="250"><b>PRODUCTO</b></TD><TD width="80" align="right"><b>CANTIDAD</b></TD><TD width="120" align="right"><b>CostE unidad</b></TD><td width="100" align="right"><b>Costo Total</b><TD width="90"> </TD></TR>');
itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == '[') {
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == ']') {
itemend = i;
thequantity = fulllist.substring(itemstart, itemend);
itemtotal = 0;
itemtotal = (eval(theprice*thequantity));
temptotal = itemtotal * 100;
var tax = itemtotal / 100 * (0 - 0);
tax = Math.floor(tax * 100)/100
totprice = totprice + itemtotal + tax;
itemlist=itemlist+1;
document.writeln('<tr><td>'+theitem+'</td><td align=right>'+thequantity+'</td><td align=right>'+theprice+'</td><td align=right>'+alterError(itemtotal)+'</td><td align=center><input TYPE="button" NAME="remove" VALUE="TREURE-HO" onclick="javascript:removeItem('+itemlist+')"></td></tr>');
} else if (fulllist.substring(i,i+1) == ',') {
theitem = fulllist.substring(itemstart, i);
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == '#') {
theprice = fulllist.substring(itemstart, i);
itemstart = i+1;
}
}
document.writeln('<tr><td colspan=3><b>Total</b></td><td align=right>'+alterError(totprice)+'</td><td> </td></tr>');
document.writeln('</TABLE>');
}