function boardSize() {
var rows = 3;
var cols = 3;
document.write(" <table> ");
for (i = 0; i < rows; i++) {
document.write("<tr>");
for (j = 0; j < cols; j++) {
var btncolo;
var btnarr = ["red", "blue", "yellow"];
var x = Math.floor((Math.random() * 3) + 1);
btncolo = btnarr[x - 1];
var stringArray = ["<td><input type='button' style=backgroundcolor:'", btncolo, "' onclick='hitheadr('id')'> </td>"];
document.write(stringArray.join(""));
}
document.write("</tr>");
}
document.write(" </table>");
}
I have been trying with this for displaying table in the same page but I could not get the result.
I know the reason that I am using document.write()
gives the result in other page.
What can I use to get the desired result?