Salve vi posto il codice js:
Codice PHP:
function GameBoard(){ 
    
this.initTable = function(rowcoltableWidthtableHeight){
        
//var text = document.createTextNode("&nbsp");
        
var table document.getElementById("scacchiera");
        var 
idCounter 0;
        var 
tableDate null;
        var 
tableRow null;
        for(
righe 0righe rowrighe++){
            
tableRow document.createElement("tr");
            for(
colonne 0colonne colcolonne++){
                
tableDate document.createElement("td");
                
tableDate.ycolonne;
                
tableDate.x=righe;
                
tableDate.setAttribute("id"idCounter);
                
//---------da css-------------
                
tableDate.setAttribute("width""80");
                
tableDate.setAttribute("height""80");
                
//----------------------------
                
tableDate.onclick = function() {gameBoard.setPedina(idCounter)};
                
tableRow.appendChild(tableDate);
                
idCounter++
            }
            
tableRow.setAttribute("bgcolor""red");//css
            
table.appendChild(tableRow);
        }
        
table.setAttribute("border""1");//css
        
table.style.width=tableWidth;//css
        
table.style.height=tableHeight;//css
    
}
    
    
this.setPedina = function(id) {
        var 
pedinaRossa = new Image();
        
pedinaRossa.src="pedina.jpeg";

        
//var id = .getAttribute("id");
        
var tableDate document.getElementById(id);
alert(id);
        var 
img document.createElement("img");
        
img.src pedinaRossa.src;
        
img.width=80;//css
        
img.height=80;//css
        
img.setAttribute("border""1");//css
        
tableDate.appendChild(img);
    }
    
this.isAlive = function() {
        
alert("isAlive");
    }

allora, creo in modo dinamico una tabella 8x8 caselle e assegno ad ogni tag "td" un id con idCounter per poi chiamare, all'evento onclick setPedina con l'id relativo della cella.
Il problema è che su qualsiasi cella clicchi mi da id = 64!
Ovvio che mi sfugge qcs...