469,344 Members | 6,255 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

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



Expand|Select|Wrap|Line Numbers
  1. var easy=[["1","","5","","","2","","5","","1"],
  2.           ["","1","","2","6","","3","","","4"],
  3.           ["2","","8","","","","","5","7",""],
  4.           ["3","2","","","2","","2","","","9"],
  5.           ["","4","5","","","","","5","",""],
  6.           ["7","","","2","3","","4","","6",""],
  7.           ["","4","","9","","","","8","","3"],
  8.           ["8","1","4","","9","","","","",""],
  9.           ["2","","8","7","","","9","","2","1"],
  10. ];//end of arrays   
  11.  
  12. for(col=0;col<column;col++)
  13.             {
  14.  
  15.             for(rw=0;rw<row;rw++)
  16.                 {
  17.                         var id=document.getElementById('R'+rw+'C'+col).innerHTML=easy[col][rw];//adding value into table
  18. }
  19. }
  20.  
  21. //tring to get values 
  22.     for(col=0;col<column;col++)
  23.             {
  24.             for(rw=0;rw<row;rw++)
  25.                 {
  26.                     var ID='R'+rw+'C'+col;
  27.                     console.log(ID);
  28.                     var d =document.forms[ID].elements["fv"].value;
  29.                 }
  30.             }
Feb 15 '12 #1
1 1516
I'm not sure if this makes a difference, but try adding var to the variables in your for loops.

E.g.

Expand|Select|Wrap|Line Numbers
  1. for(var col=0;col<column;col++)
  2.  
Feb 17 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Jorgen Gustafsson | last post: by
2 posts views Thread by David | last post: by
2 posts views Thread by darrel | last post: by
11 posts views Thread by John Salerno | last post: by
reply views Thread by John Wright | last post: by
5 posts views Thread by SneakyElf | last post: by
Thekid
9 posts views Thread by Thekid | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.