Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. function insertObject() {
  2.  
  3.  
  4. var data = [{
  5. "nodeid": 1,
  6. "vendor": "0x0345,0x0342,0x0323,0x0321",
  7. "product_id": "",
  8. "product_type": "",
  9. "home_id": "0xD087E344",
  10. "secure": "1",
  11. "button" : "-",
  12. },
  13. {
  14. "nodeid": 2,
  15. "vendor": "0x0285",
  16. "product_id": "",
  17. "product_type": "",
  18. "home_id": "0xD087D213",
  19. "secure": "0",
  20. "button" : "-",
  21. },
  22. { "nodeid": 3,
  23. "vendor": "0x1145",
  24. "product_id": "",
  25. "product_type": "",
  26. "home_id": "0xD034T13",
  27. "secure": "0",
  28. "button" : "-",
  29. },
  30. { "nodeid": 4,
  31. "vendor": "0x8992",
  32. "product_id": "",
  33. "product_type": "",
  34. "home_id": "0xD0682F13",
  35. "secure": "1",
  36. "button" : "-",
  37. }
  38. ];
  39.  
  40. var text=[];
  41. var tbl = document.getElementById('tableData');
  42. var tblBody = document.createElement('tbody');
  43. for (var i = 0; i < data.length; i++) {
  44. var split =data[i].vendor.split(",");
  45.  
  46. data[i]["vendor"]=split[0];
  47. data[i]["product_id"]=split[1];
  48. data[i]["product_type"]=split[2];
  49.  
  50.  
  51.  
  52. var row = document.createElement('tr');
  53. for (var value in data[i]) {
  54.  
  55. var cell = document.createElement("td");
  56. var cellText = document.createTextNode(data[i][value]);
  57. cell.appendChild(cellText);
  58. row.appendChild(cell);
  59. }
  60. tblBody.appendChild(row);
  61. }
  62. tbl.appendChild(tblBody);
  63.  
  64.  
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement