S
SoLRaC
I have a form, and i want with javascript round a number with 2
decimals to de uper next 0 or five.
IE if you have the number 4,53 it must be rounded to 4,55. Until now i
wrote that
var valor
function redondeo(valor){
valor= valor *100;
if (valor/5!=Math.floor(valor/5)){
valor=valor+1;
}
if (valor/5!=Math.floor(valor/5)){
valor=valor+1;
}
if (valor/5!=Math.floor(valor/5)){
valor=valor+1;
}
if (valor/5!=Math.floor(valor/5)){
valor=valor+1;
}
if (valor/5!=Math.floor(valor/5)){
valor=valor+1;
}
valor=valor/100;
}
But when i call to de function it wrote me in the text box "nan" (not
a number i supose)
document.f1.t1.value=redondeo((document.f1.pvp1.value)*(document.f1.u1.value));
any help would be welcome, sorry for my poor english and greetings
from spain
decimals to de uper next 0 or five.
IE if you have the number 4,53 it must be rounded to 4,55. Until now i
wrote that
var valor
function redondeo(valor){
valor= valor *100;
if (valor/5!=Math.floor(valor/5)){
valor=valor+1;
}
if (valor/5!=Math.floor(valor/5)){
valor=valor+1;
}
if (valor/5!=Math.floor(valor/5)){
valor=valor+1;
}
if (valor/5!=Math.floor(valor/5)){
valor=valor+1;
}
if (valor/5!=Math.floor(valor/5)){
valor=valor+1;
}
valor=valor/100;
}
But when i call to de function it wrote me in the text box "nan" (not
a number i supose)
document.f1.t1.value=redondeo((document.f1.pvp1.value)*(document.f1.u1.value));
any help would be welcome, sorry for my poor english and greetings
from spain