Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

test.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. var request = new XMLHttpRequest()
  2. /*request.open('GET', 'json/renglones.json', true)
  3. request.onload = function() {
  4. // begin accessing JSON data here
  5. var info = JSON.parse(this.response)
  6. var table = document.getElementById("table");
  7. for (var i = 0; i < info.length; i++) {
  8. tr = table.insertRow(-1);
  9. for (var j = 0; j < 2; j++) {
  10. var tabCell = tr.insertCell(-1);
  11. if (j==0) {
  12. tabCell.innerHTML = info[i].Renglones;
  13. }
  14. else{
  15. tabCell.innerHTML = info[i].Especificaciones;
  16. }
  17. }
  18. }
  19. var divContainer = document.getElementById("showData");
  20. divContainer.innerHTML = "";
  21. divContainer.appendChild(tr);
  22. }*/
  23. request.open('GET', 'json/MADERA.json', true)
  24. request.onload = function() {
  25. // begin accessing JSON data here
  26. var info = JSON.parse(this.response)
  27. var table = document.getElementById("table");
  28. for (var i = 0; i < info.length; i++) {
  29. tr = table.insertRow(-1);
  30. for (var j = 0; j < 5; j++) {
  31. var tabCell = tr.insertCell(-1);
  32. if (j==0) {
  33. tabCell.innerHTML = info[i].Nombre;
  34. }
  35. else if (j==1) {
  36. tabCell.innerHTML = info[i].Especificaciones;
  37. }
  38. else if (j==2) {
  39. tabCell.innerHTML = info[i]["Teléfono 1"];
  40. }
  41. else if (j==3) {
  42. tabCell.innerHTML = info[i]["E-mail"];
  43. }
  44. else{
  45. tabCell.innerHTML = info[i].Municipio
  46. }
  47. }
  48. }
  49. var divContainer = document.getElementById("showData");
  50. divContainer.innerHTML = "";
  51. divContainer.appendChild(tr);
  52. }
  53. request.send()