hello, thank you to all that reply my problem. The topic is that:
i have a for that show different content in the table, an for iteration by each table cell
[code]for(i=0; i< event_cel.lenght; i++){
…..
var pasando = ‘celda’+(eve[i][2]+dia_i);
pasando=pasando.toString();
crearEvento(elem,’click’, function(){dale(pasando);});
crearEvento(elem,’mouseover’, function({document.getElementById(pasando).style.border=”2px #FFCC00 solid”;});
crearEvento(elem,’mouseout’, function(){document.getElementById(pasando).style.border=”0px #FFFFFF solid”;});
}
the events are assigned but this tree events in all cells that i apply thus, had the same fuction´s arguments.
When i pass over cell 1 show the message that would show in the last cell iterated, understand?
cell1 innerHTML -> HOLA
cell 5 innerHTML -> CHAU
cell 10 innerHTML -> COMO ESTAN
when i pass the mouse over, out or click in each cell, all work like if all events work just for the last cell. If it would happend with the first, i would think that the for isnt work properly, but not, is with the last.
would imagine that i want make a table where each cell had their mouseout and over that affect with special effects to each one, but when i pass mouse over each cell, always modify the last :S ?
Can Someone help me? Thank you so much
[CODE]for(i=0; i< event_cel.lenght; i++){[/CODE]
[CODE]for(i=0; i< event_cel.length; i++){[/CODE]
[CODE]function shows(mesp,anop){
var eve=window['eventos'];
var dia_i=calculaNumeroDiaSemana(1,mesp,anop);
for(var i=0;i<eve.length;i++)
if(eve[i][0]==anop && eve[i][1]==(mesp+1)){
var elem=new Object();
elem=document.getElementById('celda'+(eve[i][2]+dia_i));
esta=false;
for(var g=0;g<window['evento_celda'].length;g++)
if(window['evento_celda'][g][0]=='celda'+(eve[i][2]+dia_i)){esta=true; window['evento_celda'][g][4]+=1;}
if(!esta){
var tempi=new Array();
tempi=["celda"+(eve[i][2]+dia_i),elem.innerHTML,mesp,anop,1];
window['evento_celda'].push(tempi);
//alert('EVENTO_CELDA: '+window['evento_celda'].length);
elem.style.color="#FFFFFF";
elem.style.backgroundColor="#00CCFF";
elem.style.fontWeight="bold";
elem.style.cursor='pointer';
}
//elem.innerHTML=eve[i][2];
//eve[i][2],eve[i][1],eve[i][0]
//'+eve[i][2]+','+eve[i][1]+','+eve[i][0]+'
/*pasando = 'celda'+(eve[i][2]+dia_i);
pasando=pasando.toString();
(function (i){document.getElementById(pasando).onclick = function() {dale(pasando);};})(i);
(function (i){document.getElementById(pasando).onmouseover = function () {document.getElementById(pasando).style.border="2px #FFCC00 solid";};})(i);
(function (i){document.getElementById(pasando).onmouseout = function () {document.getElementById(pasando).style.border="0px #FFFFFF solid";};})(i);*/
/*
These are some tryes that did for see if work in some way
(function(i){crearEvento(elem,'click', function(){dale(pasando);});})(i);
(function(i){crearEvento(elem,'mouseout', function(){fonmouseout(pasando);});})(i);
(function(i){crearEvento(elem,'mouseover', function(){fmouseover(pasando);});})(i);
*/
//crearEvento(elem,'mouseover', function(){fmouseover(pasando);});
/*crearEvento(elem,'click', (function(i){dale(pasando);})(i));
crearEvento(elem,'mouseover', (function(i){fmouseover(pasando);})(i));
crearEvento(elem,'mouseout', (function(i){fonmouseout(pasando);})(i));
Finally i has been added "onmouseover=fonmouseover(this)" in html source by each table cell and then when call the function i check if id´s cell correspond to special cell to start the real work function made for*/
}
var ari = new Array();
ari = window['evento_celda'];
for(var g=0; g<ari.length; g++)
if(ari[g][4]>1)
document.getElementById(ari[g][0]).innerHTML+='<sup>('+ari[g][4]+')</sup>';
return true;
}[/CODE]
[code=html]...<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="img/Domingo.jpg" width="40" height="40" /></td>
<td><img src="img/Lunes.jpg" width="40" height="40" /></td>
<td><img src="img/Martes.jpg" width="40" height="40" /></td>
<td><img src="img/Miercoles.jpg" width="40" height="40" /></td>
<td><img src="img/Jueves.jpg" width="40" height="40" /></td>
<td><img src="img/Viernes.jpg" width="40" height="40" /></td>
<td><img src="img/Sabado.jpg" width="40" height="40" /></td>
</tr>
<tr>
<td onmouseover="fmouseover(event,event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda1"></td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda2"></td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" style="height:30px" align="center" id="celda3"></td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda4"></td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);"align="center" id="celda5"></td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda6"></td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda7"></td>
</tr>
<tr>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda8"></td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda9"></td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" style="height:30px" align="center" id="celda10"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda11"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda12"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda13"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda14"> </td>
</tr>
<tr>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda15"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda16"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" style="height:30px" align="center" id="celda17"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda18"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda19"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda20"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda21"> </td>
</tr>
<tr>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda22"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda23"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" style="height:30px" align="center" id="celda24"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda25"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda26"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda27"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda28"> </td>
</tr>
<tr>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda29"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda30"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" style="height:30px" align="center" id="celda31"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda32"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda33"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda34"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda35"> </td>
</tr>
<tr>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda36"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda37"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" style="height:30px" align="center" id="celda38"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda39"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda40"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda41"> </td>
<td onmouseover="fmouseover(event,this);" onmouseout="fonmouseout(this);" onclick="dale(this);" align="center" id="celda42"> </td>
</tr>
</table>....[/code]
function crearEvento(elemento, evento, funcion) {
if (elemento.addEventListener) {
elemento.addEventListener(evento, funcion, false);
} else {
elemento.attachEvent("on" + evento, funcion);
}
return true;
}
function removeEvent(node ,evt, fnc){
if (node.removeEventListener)
node.removeEventListener(evt,fnc,false);
else if (node.detachEvent){
node.detachEvent('on'+evt,fnc);
}
else
return false;
return true;
}
[CODE]function createMouseover(pasando) {
return function() {
document.getElementById(pasando).style.border="2px #FFCC00 solid";
};
}
function createMouseout(pasando) {
return function() {
document.getElementById(pasando).style.border="0px #FFFFFF solid";
};
}
function createClick(pasando) {
return function() {
dale(pasando);
};
}[/CODE]
[CODE]var pasando = 'celda'+(eve[i][2]+dia_i);
pasando=pasando.toString();
crearEvento(elem,'click', createClick(pasando));
crearEvento(elem,'mouseover', createMouseover(pasando));
crearEvento(elem,'mouseout', createMouseout(pasando));[/CODE]
[CODE]for(i=0; i< event_cel.lenght; i++){
.....
[COLOR="Red"](function scope(i){[/COLOR]
var pasando = 'celda'+(eve[i][2]+dia_i);
pasando=pasando.toString();
crearEvento(elem,'click', function(){dale(pasando);});
crearEvento(elem,'mouseover', function({document.getElementById(pasando).style.border="2px #FFCC00 solid";});
crearEvento(elem,'mouseout', function(){document.getElementById(pasando).style.border="0px #FFFFFF solid";});
[COLOR="Red"]}(i));[/COLOR]
}[/CODE]
changes to post #1 in red:
[CODE]for(i=0; i< event_cel.lenght; i++){
.....
[COLOR="Red"](function scope(i){[/COLOR]
var pasando = 'celda'+(eve[i][2]+dia_i);
pasando=pasando.toString();
crearEvento(elem,'click', function(){dale(pasando);});
crearEvento(elem,'mouseover', function({document.getElementById(pasando).style.border="2px #FFCC00 solid";});
crearEvento(elem,'mouseout', function(){document.getElementById(pasando).style.border="0px #FFFFFF solid";});
[COLOR="Red"]}(i));[/COLOR]
}[/CODE]
edit: you don't even need the "i" in this example because pasando is now private ...[/QUOTE]
[CODE] var esta = false;
avanti=window['evento_celda'];
for(var u=0; u<avanti.length;u++)
if(avanti[u][0]==atemp.id){ esta=true;}
if(!esta) {return;}
var a= new Date();
var atiempo=a.getTime();
if((atiempo-window['fix_events'])<3){
window['fix_events']=atiempo;
return false;
}[/CODE]
0.1.9 — BETA 6.2