onclick error

posted by hakon on 2010-04-20 18:22:12
hi, i have made a simple tic-tac-toe implementation as practice and i use a table as the playingfield. i fill in the tiles with this code (field is a reference to the )
 
...
  for(y=0;y<size;y++){ //add rows
    field.appendChild(document.createElement('tr')); //add a row
    for(x=0;x<size;x++){ //add tiles
      field.lastChild.appendChild(document.createElement('td')); //add a tile
      field.lastChild.lastChild.appendChild(document.createTextNode('')); //add empty text
      field.lastChild.lastChild.onclick = 'move('+x+','+y+');'; //onclick = take the tile
    }
  }
...
 
if the tiles get clicked, they should call move(x,y) with their respective coordinates, but until now nothing happens when i click them (the game works flawlessly when i call the move-function in the firebug console)
could someone please tell me what the correct code would be? thanks in advance!
--hakon
hakon
0
i messed this up, this should be javascript , but there is no way of changing it now :-P
also, in line 2 it should read "reference to the table" it got left out because i but it in angle brackets
1 answers - 1 questions
  Positive        Negative



Answer the question



Top Users
  • dail (12)
  • livin52 (3)
  • camu (3)
  • softweb (2)
  • Nadine (1)
  • Josware (1)
  • lfelipecr (1)
  • gregoriohc (1)
  • Mitu (1)
  • ryan714 (1)