Ver Mensaje Individual
  #11 (permalink)  
Antiguo 30/05/2003, 10:38
Avatar de JavierB
JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 23 años
Puntos: 772
Hola a todos.

Os dejo otro método para controlar el nº de decimales:
Código PHP:
<html>
<
head>
<
script>
Number.prototype.decimal = function (num) {
    
pot Math.pow(10,num);
    return 
parseInt(this pot) / pot;
}
function 
decimal(src) {
    
n=eval(document.getElementById(src).value);
    
alert(n.decimal(3)); //deja 3 decimales
}
</script>
</head>

<body>
<input type="text" id="numero" value="3.1415926">
<input type="button" onClick="decimal('numero')">
</body>
</html> 
Espero que resulte útil. Saludos,