for (n=0; n<10; n++) { a[n] = document.createElement('input'); a[n].onclick = 't = event.target; t.value = "X"'; document.getElementById('mytable').appendChild(a[n]); }