
11/01/2008, 02:06
|
 | Moderador extraterrestre | | Fecha de Ingreso: diciembre-2001 Ubicación: Madrid
Mensajes: 6.987
Antigüedad: 23 años, 2 meses Puntos: 61 | |
Re: Porcentaje entre dos cifras <html>
<head>
<title>Untitled</title>
<script>
function valor(x){
p=parseInt(x);
y=(isNaN(p))?0:x;
return y;
}
function calcular(f){
total = valor ( Math.round ( 10000 * valor ( f.precioVenta.value ) / valor (f.precioCompra.value ) ) / 100 );
f.porcentaje.value=""+total+" %";
}
</script>
<style>
form{
font:normal 10px/10px verdana;
}
</style>
</head>
<body>
<form>
Precio Compra:<br />
<input type="text" name="precioCompra" onkeyup="calcular(this.form)" /><br />
Porcentaje de Utilidad:<br />
<input type="text" name="porcentaje" size="6" readonly="readonly" /><br />
Precio Venta:<br />
<input type="text" name="precioVenta" onkeyup="calcular(this.form)" />
</form>
</body>
</html>
__________________ Cómo escribir
No hay pregunta tonta, sino tonto que quiere seguir en la ignorancia.
Última edición por KarlanKas; 20/01/2008 a las 04:18 |