javascript - Finding value of each member of a column in grid (JS) -
i having bit of issue , hoping can help. beginner @ js might have simple answer going on head.
i have grid can dynamically created based on user specified rows , columns. have array of row numbers , array of col numbers , attributed id each member using formula:
index = (maxcols * rownumber) + col;
i have added id each member of grid, resulting this:
1 2 3 4 5 6 7 8 9
basically trying find value of every member of column , add own array. in case answer might
column1 [1,4,7]; column2 [2,5,8]; column3 [3,6,9];
the result im going allow me find relative column having member id. push in right direction fantastic. in advance!
if understand correctly, can this:
var maxcol = 4, maxline = 4, col = 2, line = 3; var index = (maxcol * line) + col; var foundcol = index % maxcol; // found column var foundline = (index - col) / maxline; // found line console.log(index, foundcol, foundline);
then loop through indexes , add columnsvalues[foundcol] value.
does ?
Comments
Post a Comment