Browse Source

first collect all data to write into variable 'htmlOutput' and then write it in one bunch into the html file with the 'innerHtml' method

master
T. Meissner 12 years ago
parent
commit
d02d2f36c1
1 changed files with 15 additions and 12 deletions
  1. +15
    -12
      scripts/haltestellen.js

+ 15
- 12
scripts/haltestellen.js View File

@ -55,8 +55,7 @@ function ajaxCall(dataUrl, outputElement, callback) {
console.log("anonymous function"); console.log("anonymous function");
var wurst = [["13","Prohlis","754"],["13","Prohlis","754"],["13","Prohlis","754"],["13","Prohlis","754"]];
console.log(wurst[0][0]);
//var wurst = [["13","Prohlis","754"],["13","Prohlis","754"],["13","Prohlis","754"],["13","Prohlis","754"]];
// get the search form // get the search form
var searchForm = document.getElementById("search-form"); var searchForm = document.getElementById("search-form");
@ -80,24 +79,28 @@ function ajaxCall(dataUrl, outputElement, callback) {
var i; var i;
var y; var y;
var htmlOutput;
var dataLength = data.length; var dataLength = data.length;
target.innerHTML = "<table>";
target.innerHTML += "<tr>";
target.innerHTML += "<th>Linie</th>";
target.innerHTML += "<th>Richtung</th>";
target.innerHTML += "<th>Abfahrt</th>";
target.innerHTML += "</tr>";
htmlOutput = "<table>";
htmlOutput += "<tr>";
htmlOutput += "<th>Linie</th>";
htmlOutput += "<th>Richtung</th>";
htmlOutput += "<th>Abfahrt</th>";
htmlOutput += "</tr>";
for (i = 0; i < dataLength; i++) { for (i = 0; i < dataLength; i++) {
target.innerHTML += "<tr>";
htmlOutput += "<tr>";
for (y = 0; y < 3; y++) { for (y = 0; y < 3; y++) {
target.innerHTML += "<td>" + data[i][y] + "</td>";
htmlOutput += "<td>" + data[i][y] + "</td>";
} }
target.innerHTML += "</tr>";
htmlOutput += "</tr>";
} }
target.innerHTML += "</table>";
htmlOutput += "</table>";
// print table into web page
target.innerHTML = htmlOutput;
}); });
} }
}; };


Loading…
Cancel
Save