How to update the value in table by using id of particular field

there is a table with five rows and five columns and at first it will be empty once i click on any cell in the table the random number should appear automatically in that particular cell.
( for ex if i tried to print random numbers from 1-10 then if i click on one cell the random number should generate and show in the particular cell the process should applied for all the cells in the table ).
thanks in advance