Ver Mensaje Individual
  #5 (permalink)  
Antiguo 04/01/2008, 22:10
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años, 9 meses
Puntos: 834
Re: Ayuda JSON !!

Se me anticipo derkenuke. this, en ese contexto, apunta al objeto tablero y no a la tabla. Además, para agregar los renglones y que funcione en todos los navegadores modernos, hay que crear un elemento tbody. Finalmente, para que lo tome Explorer, bgcolor debe definirse como bgColor (sintaxis camel case: con la c en mayúscula):
Código PHP:
<!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=iso-8859-1" />
<
title>Documento sin t&iacute;tulo</title>
<
script>


var 
tablero = {

dibujar:function(filas,columnas) {
//alert(filas+'---'+columnas)
var tabla document.createElement("table");
tabla.id='tablita'
cuerpo=document.createElement("tbody");
for (var 
i=0i<filasi++) {
var 
fila document.createElement("tr");


for (var 
j=0j<columnasj++) {
    var 
columna document.createElement("td");
    var 
text=document.createTextNode(i+"--"+j);
    
columna.appendChild(text);
    
fila.appendChild(columna);

}
cuerpo.appendChild(fila);
}

tabla.appendChild(cuerpo);
tabla.border='1';
document.body.appendChild(tabla);
},

Activar:function() {
alert("activar");
document.getElementById('tablita').onmouseover=function() { this.setAttribute("bgColor","red"); };
document.getElementById('tablita').onmouseout=function() { this.removeAttribute("bgColor"); };
document.getElementById('tablita').onclick=function() { alert("ele")}
},

interfaz: function() {
document.getElementById('tablita').setAttribute("bgColor","red");
},
probando: function() {alert("hoa");}
};
window.onload=function() {

tablero.dibujar(10,10);
tablero.Activar();
}
</script>
</head>

<body>
</body>
</html> 

Última edición por Panino5001; 04/01/2008 a las 22:15