From d02d2f36c180deabc925caa68a31821a003da701 Mon Sep 17 00:00:00 2001 From: tmeissner Date: Mon, 25 Feb 2013 16:27:40 +0100 Subject: [PATCH] first collect all data to write into variable 'htmlOutput' and then write it in one bunch into the html file with the 'innerHtml' method --- scripts/haltestellen.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/scripts/haltestellen.js b/scripts/haltestellen.js index 6d1925b..d1fb765 100644 --- a/scripts/haltestellen.js +++ b/scripts/haltestellen.js @@ -55,8 +55,7 @@ function ajaxCall(dataUrl, outputElement, callback) { 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 var searchForm = document.getElementById("search-form"); @@ -80,24 +79,28 @@ function ajaxCall(dataUrl, outputElement, callback) { var i; var y; + var htmlOutput; var dataLength = data.length; - target.innerHTML = ""; - target.innerHTML += ""; - target.innerHTML += ""; - target.innerHTML += ""; - target.innerHTML += ""; - target.innerHTML += ""; + htmlOutput = "
LinieRichtungAbfahrt
"; + htmlOutput += ""; + htmlOutput += ""; + htmlOutput += ""; + htmlOutput += ""; + htmlOutput += ""; for (i = 0; i < dataLength; i++) { - target.innerHTML += ""; + htmlOutput += ""; for (y = 0; y < 3; y++) { - target.innerHTML += ""; + htmlOutput += ""; } - target.innerHTML += ""; + htmlOutput += ""; } - target.innerHTML += "
LinieRichtungAbfahrt
" + data[i][y] + "" + data[i][y] + "
"; + htmlOutput += ""; + + // print table into web page + target.innerHTML = htmlOutput; }); } };