![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
17/11/2004, 15:10
|
| | Fecha de Ingreso: octubre-2004 Ubicación: España
Mensajes: 894
Antigüedad: 20 años, 3 meses Puntos: 3 | |
Esto para los euros:
Código:
function parse2Euros(f) {
if(!isNaN(parseFloat(f.intro.value))) {
redondeo=parseFloat(f.intro.value)/euroValue;
redondeoMil=""+redondeo*1000;
redondeoMilF=0.0;
if(redondeoMil.indexOf(".")>0) {
redondeoMilF=parseFloat(redondeoMil.substring(0,redondeoMil.indexOf(".")));
}
else {
redondeoMilF=parseFloat(redondeoMil);
}
ajuste=Math.round(redondeoMilF/10)/100;
ajuste=ajuste.toString()
i=ajuste.indexOf(".");
var ajuste1 = '';
if (i!=-1) {
ajuste1 = ','+ajuste.substr(i+1) // tras coma
ajuste=ajuste.substring(0,i) //pre-coma
}
var k=ajuste.length
var ajuste2=''
if (k>9) { ajuste2+=ajuste.substring(0,k-9)+'.' }
if (k>6) { ajuste2+=ajuste.substring(k-9,k-6)+'.' }
if (k>3) { ajuste2+=ajuste.substring(k-6,k-3)+'.' }
ajuste2+=ajuste.substr(k-3)
f.resultado.value=ajuste2+ajuste1+" Euros";
}
}
Espero que funcione, pues no consigo entender toda la función.
__________________ Angel :cool: |