I am trying to create a table, that when you input a value, it will grab this data and put random numbers between 1-99 and some can be blank, I have created it with DOM here
for (i = 0; i < NumberOfCells / NumberOfCellsInRow; i++) {
Row = document.createElement("tr")
Row.setAttribute("id", i + 1 + "tr")
document.getElementById("table").appendChild(Row)
AmountOfRows = i + 1;
}
for (i = 0; i < NumberOfCells; i++) {
temporaryVar = randomInt(1,99, 23)
Cell = document.createElement("td")
Cell.innerHTML = temporaryVar;
Cell.setAttribute("id", i + 1 + "td")
document.getElementById(Math.floor(i/NumberOfCellsInRow+1)
+"tr").appendChild(Cell)
}
This works excellently so far, but I want to take this exact table and turn it into a multidimensional array. I have thought of doing
if (i/NumberOfCellsInRow+1 < NumberOfCellsInRow) {
table.push(new Array(temporaryVar))
}
and I know this is close, but I don't know what else to do
Example: All the numbers will be random but I would have a table that looks like this and I want the array to look like
45 10 "blank" 16
44 53 88 "blank"
9 "blank" "blank" "blank"
82 63 43 "blank"
so then
table = [45, 10, " ", 16],
[44, 53, 88, " "],
[9, " ", " ", " "],
[82, 63, 43, " "]
Notes: I would like to not create the array first just in case there is anything that I want to change that would make that break