View Single Post
Old 10-10-2012, 11:04 PM   PM User | #4
ryan1234
New to the CF scene

 
Join Date: Oct 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
ryan1234 is an unknown quantity at this point
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.
ryan1234 is offline   Reply With Quote