How to loop through & display Javascript Multidimensional Array -


i have testing search software , stores data in multidimensional array. can return whole database cannot return 1 value. i'm trying figure out how return 1 section multidimensional array. otherwise repeats passed value across display. while de-bugging can see complete array stored argument having trouble figuring out how loop through array display correctly. may need view source understand better. if enter lets 439023483 , click search isbn button, see issue. show button works fine. pointing me in right direction appreciated , thank in advance.

here link testing source: http://mdhmotors.com/jstesting/test.html

here part of code i'm stuck on:

function searchbyisbn(isbn) {     var isbn = document.getelementbyid('isbn').value;     showbooks(getbookbyisbn(isbn));  } function getbookbyisbn(isbn) {   var foundbook = null;   (b in bookstore)   {       var book = bookstore[b];       if (book[isbn] == isbn)       {           foundbook = new array(book[isbn], book[title], book[author], book[publisher], book[ws_price], book[ret_price], book[quantity]);           break;       }   }   return foundbook;  }  /*display search results*/ function showbooks(searchresults) {   //cleardisplaytable();   if (searchresults == null)   {       return;   }   var row, cell, displaytable, tableheader, tabletitle;   displaytable = document.createelement('table');   displaytable.classname = "mytable";   tablebody = document.createelement('tbody');   row = document.createelement('tr');   tableheader = document.createelement('th');   tableheader.appendchild(document.createtextnode("book store inventory"));   tableheader.setattribute('colspan', 8);   tableheader.setattribute('style', 'font-size: 22px');   row.appendchild(tableheader);   tablebody.appendchild(row);   row = document.createelement('tr');  columnname = document.createelement('th');  columnname.appendchild(document.createtextnode("#"));  row.appendchild(columnname);   columnname = document.createelement('th');  columnname.appendchild(document.createtextnode("isbn"));  row.appendchild(columnname);   columnname = document.createelement('th');  columnname.appendchild(document.createtextnode("title"));  row.appendchild(columnname);   columnname = document.createelement('th');  columnname.appendchild(document.createtextnode("author"));  ow.appendchild(columnname);   columnname = document.createelement('th');  columnname.appendchild(document.createtextnode("publisher"));  row.appendchild(columnname);   columnname = document.createelement('th');  columnname.appendchild(document.createtextnode("w/s"));  row.appendchild(columnname);   columnname = document.createelement('th');  columnname.appendchild(document.createtextnode("retail"));  row.appendchild(columnname);   columnname = document.createelement('th');  columnname.appendchild(document.createtextnode("qty"));  row.appendchild(columnname);  tablebody.appendchild(row);    var count = 0;   (b in searchresults)   {     row = document.createelement('tr');     book = searchresults[b];     var data = new array(++count, book[isbn], book[title], book[author], book[publisher], book[ws_price], book[ret_price], book[quantity]);       (var index = 0; index < 8; index++)       {           cell = document.createelement('td');           celltext = document.createtextnode(data[index]);            if (index == 0)           cell.setattribute('style', 'text-align: right');           cell.appendchild(celltext);           row.appendchild(cell);       }    tablebody.appendchild(row);    } displaytable.appendchild(tablebody); bookresults.appendchild(displaytable); } 

to return value in multidimensional array: array[n][m] mth element of nth row. every element, use embedded for-loops:

for (var = 0; < array.length; i++){     (var j = 0; j < array[i].length; j++){         console.log(array[i][j]); 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -