www.webdeveloper.com
Results 1 to 2 of 2

Thread: Storing a variable

  1. #1
    Join Date
    Sep 2008
    Posts
    47

    Storing a variable

    I have this code so far:

    function displayBlabla() {
    var filenamec = "blabla.txt";
    var txt = IO(filenamec);
    var lines = txt.split(/\r?\n/g);
    var header = lines[0].split("|");
    var tbls = "<table>\n<tr>";
    for (var j = 0; j < header.length; j++) {
    tbls += "<th>" + header[j] + "</th>\n";
    }
    tbls += "</tr>";
    for (var i = 1; i < lines.length; i++) {
    tbls += "<tr>";
    var line = lines[i].split("|");
    for (var j = 0; j < line.length; j++) {
    tbls += "<td>" + line[j] + "</td>\n";
    }
    tbls += "</tr>";
    }
    tbls += "<table>";
    var divForTable = document.getElementById("tbls");
    divForTable.innerHTML = tbls;
    }


    The file is just a txt file with 6 columns worth of information delimited by a |. What I am trying to do is change the code so that i can pull out the 6th column and store it as a variable. The 6th column will always ouput an A, B, or C for values, and I want to use those 3 letters to style that particular row depending on what letter it is. Any ideas?

  2. #2
    Join Date
    Feb 2008
    Posts
    1,666
    In the header row, header[5] represents the sixth column of the table. Likewise, for each detail row, line[5] represents the sixth column of the table.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles