Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7589557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:11:25+00:00 2026-05-30T20:11:25+00:00

I am trying to recode a sudoku game to be used in smart tv’s.

  • 0

I am trying to recode a sudoku game to be used in smart tv’s. I want to find empty cells that the puzzle didn’t fill at the beginning. I declared a 2 dimensional aray

var emptyCellsArray =new Array(9);
    emptyCellsArray[0] = new Array();
    emptyCellsArray[1] = new Array();
    emptyCellsArray[2] = new Array();
    emptyCellsArray[3] = new Array();
    emptyCellsArray[4] = new Array();
    emptyCellsArray[5] = new Array();
    emptyCellsArray[6] = new Array();
    emptyCellsArray[7] = new Array();
    emptyCellsArray[8] = new Array();

write the function

function fillEmptyCellsArray() {
for ( var i= 1 ; i<=9; i++) {
for (var k=1 ; k<=9; k++) {
        emptyCellsArray[i][k] = 0;          
};   //k end
}; //i end  

for ( var i= 1 ; i<=9; i++) {
var flag = 0;
    for (var k=1 ; k<=9; k++) {
        if ( !(document.getElementsByName(i+'_'+k)[0].value == "" )  ) {
            //add this cell to the array
            emptyCellsArray[i][flag] = 1;
            flag++; 
        }  //end if 
    };   //k end
}; //i end

alert("XX------" + emptyCellsArray[0][0]  );

}; //function end

then called the function.

$(document).ready(function () {
    fillEmptyCellsArray();
}); 

but i am getting this error output.

Error Detail : TypeError: document.getElementsByName(i + “_” + k)[0] is undefined

coming from this line—> if ( !(document.getElementsByName(i+’_’+k)[0].value == “” )

I am not pro, i couldn’t figure it out. What is my mistake? I think the problem is in the declaration part. Can anybody enlighten me?

second version now all array filled with 1’s

function fillEmptyCellsArray() {
for ( var i=0 ; i<9; i++) {
    for (var k=0 ; k<9; k++) {
        emptyCellsArray[i][k] = 0;          
    };   //k end
}; //i end  

for ( var i= 0; i<9; i++) {
    for (var k=0 ; k<9; k++) {
        if ( !(document.getElementsByName(i+'_'+k)[0].value == "" )  ) {
            //add this cell to the array
            emptyCellsArray[i][k] = 1;
        }  //end if 
    };   //k end
}; //i end

for ( var i=0 ; i<9; i++) {
    for (var k=0 ; k<9; k++) {
        alert ( emptyCellsArray[i][k] );            
    };   //k end
}; //i end  

}; //function end

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:11:26+00:00Added an answer on May 30, 2026 at 8:11 pm

    Now your example names start at 0 and your loops start at 1. Do you have 9_9 element or is the last one 8_8.

    I am guessing you really want your loops to look like this

    for ( var i= 0 ; i<9; i++) {
        var flag = 0;
        for (var k=0 ; k<9; k++) { 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to find the best way of create an overlap/overlay layer to fill the
Hi I am trying to create a packet that I want to send over
Trying to get comfortable with jQuery and I have encountered some sample code that
Example of problem http://img638.imageshack.us/img638/3733/97914817.jpg I'm trying to recode one of my older forms. It
I'm trying to use recode in R (from the car package) and it is
Trying to find some information on this but am unable to get any results
I've created a music discovery webapp that I'm trying to integrate with Facebook. The
I'm trying to put in an edittext the phone number that was selected by
I want to write a bash script that (recursively) processes all files of a
I've been trying to find a way to do this for a while now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.