Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/05/2008, 13:47
quimfv
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 2 meses
Puntos: 574
Re: Sumar valor cada segundo a un objeto

No se si es una chapuza pero me llamo la atencion tu petición y he sacado algo que se le parece:


Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script> 
var matriuobj=new Array();

function comptador(valor,lloc){
 this.valor = valor; // valor que se suma cada segundo 
 this.lloc=lloc;
}

function inicicomptador(valor,lloc){
matriuobj[matriuobj.length]=new comptador(valor,lloc);
setInterval ("time()",1000);
}

function time()
{
	for (i=0;i<matriuobj.length;i++){
	val=parseFloat(document.getElementById(matriuobj[i].lloc.toString()).innerHTML)+matriuobj[i].valor/4; 
    document.getElementById(matriuobj[i].lloc.toString()).innerHTML=val;
	}
}
</script>


</head>
<body onload="inicicomptador(1.0,'crystal');inicicomptador(15.0,'metal');">
<span id="crystal">1000</span>
<br />
<span id="metal">1000</span>
</body>
</html> 
Dime que te parece!!!

(cada vez estoy mas seguro de que es una chapuza....)


Quim