Comparing Values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jag Sol
    New Member
    • Feb 2012
    • 1

    #1

    Comparing Values

    Hi Guys!


    Im making sudoku game using javascript. i have created 9x9 table grid using JS and i managed to put values in table from JS array.

    I have released a text box instead blank table where user can enter number to play the game.

    now i want to get all the table values and text box value and compare with another array in java script but i cant seem to get the value.

    Please help or any suggestion appreciated.

    my code below

    JAVASCRIPT



    Code:
    var easy=[["1","","5","","","2","","5","","1"],
    		  ["","1","","2","6","","3","","","4"],
    		  ["2","","8","","","","","5","7",""],
    		  ["3","2","","","2","","2","","","9"],
    		  ["","4","5","","","","","5","",""],
    		  ["7","","","2","3","","4","","6",""],
    		  ["","4","","9","","","","8","","3"],
    		  ["8","1","4","","9","","","","",""],
    		  ["2","","8","7","","","9","","2","1"],
    ];//end of arrays   
    
    for(col=0;col<column;col++)
    			{
    
    			for(rw=0;rw<row;rw++)
    				{
    						var id=document.getElementById('R'+rw+'C'+col).innerHTML=easy[col][rw];//adding value into table
    }
    }
    
    //tring to get values 
    	for(col=0;col<column;col++)
    			{
    			for(rw=0;rw<row;rw++)
    				{
    					var ID='R'+rw+'C'+col;
    					console.log(ID);
    					var d =document.forms[ID].elements["fv"].value;
    				}
    			}
    Last edited by Dormilich; Feb 15 '12, 03:14 PM. Reason: Please use [CODE] [/CODE] tags when posting code.
  • Dave0291
    New Member
    • Jan 2012
    • 33

    #2
    I'm not sure if this makes a difference, but try adding var to the variables in your for loops.

    E.g.

    Code:
    for(var col=0;col<column;col++)

    Comment

    Working...