G
Glenn
When I run this code as part of a HTML page it responds with object required
Line 95 Char 5 witch I have marked in the code. Can anyone see a problem.
P.S. I am only a student, I know the code isn't very well written
Thanks
Glenn
function processClick(){
var p = 1;
var orded = true;
for(var row = 0; row <= 3; row++){ //Loop through sells array
for(var col = 0; col <= 3; col++){
*************Error********** if((event.srcElement.parentElement.id) ==
"cell" + [row] + [col] ){
swapped = false;
//Check to see if there is a white space adjacent to the
clicked cell.
if(row != 0 && (cells[row-1][col]).innerText == " "){
swap(cells[row][col],cells[row-1][col]);
}else{
if(col != 3 && (cells[row][col+1]).innerText == " "){
swap(cells[row][col],cells[row][col+1]);
}else{
if(row != 3 && (cells[row+1][col]).innerText == " "){
swap(cells[row][col],cells[row+1][col]);
}else{
if(col != 0 && (cells[row][col-1]).innerText == " "){
swap(cells[row][col],cells[row][col-1]);
}
}
}
}
if(swapped == false){
window.alert("This move is not allowed"); //If there is no white
space produce and error dialog box
}
if(cells[row][col].innerText == p){
p++;
}else{
orded = false;
}
if(orded == true){
if (confirm("Would you like to play again")){
start();
}else{
}
}
}
}
}
}
Line 95 Char 5 witch I have marked in the code. Can anyone see a problem.
P.S. I am only a student, I know the code isn't very well written
Thanks
Glenn
function processClick(){
var p = 1;
var orded = true;
for(var row = 0; row <= 3; row++){ //Loop through sells array
for(var col = 0; col <= 3; col++){
*************Error********** if((event.srcElement.parentElement.id) ==
"cell" + [row] + [col] ){
swapped = false;
//Check to see if there is a white space adjacent to the
clicked cell.
if(row != 0 && (cells[row-1][col]).innerText == " "){
swap(cells[row][col],cells[row-1][col]);
}else{
if(col != 3 && (cells[row][col+1]).innerText == " "){
swap(cells[row][col],cells[row][col+1]);
}else{
if(row != 3 && (cells[row+1][col]).innerText == " "){
swap(cells[row][col],cells[row+1][col]);
}else{
if(col != 0 && (cells[row][col-1]).innerText == " "){
swap(cells[row][col],cells[row][col-1]);
}
}
}
}
if(swapped == false){
window.alert("This move is not allowed"); //If there is no white
space produce and error dialog box
}
if(cells[row][col].innerText == p){
p++;
}else{
orded = false;
}
if(orded == true){
if (confirm("Would you like to play again")){
start();
}else{
}
}
}
}
}
}