The couple of functions I have are:
Code:
function save() {
//for (var i = 0; i <= 8; i++) {
// myArray[i] = new Array(9);
// for (var j = 0; j <= 8; j++) {
// myArray[i][j] = '';
//}
//}
var col, row;
for (row = 0; row <=8; row++) {
for (col=0; col <= 8; col++) {
var cell = document.getElementById('cell_' + col + '_' + row);
if (parseInt(cell.innerHTML)) {
myArray[[col][row]] = cell.innerHTML;
}
}
}
}
function restore() {
var col, row;
for (row = 0; row <=8; row++) {
for (col=0; col <= 8; col++) {
var cell = document.getElementById('cell_' + col + '_' + row);
if (parseInt(cell.innerHTML)) {
document.getElementById('cell_' + col + '_' + row).innerHTML = myArray[[col][row]];
}
else {
document.getElementById('cell_' + col + '_' + row).innerHTML = '';
}
}
}
}
The array is declared earlier in the code.
Basically I use the save() function to save values from a table into the array. However when I don't enter a value into a particular cell (so that bit of array is empty), save it and press restore, it then puts a 6 into the cell.
Any ideas.