Multi Row Table

Discussion in 'Javascript' started by jaykappy, Oct 22, 2015.

  1. jaykappy

    jaykappy

    Joined:
    Oct 18, 2015
    Messages:
    5
    Likes Received:
    0
    I am using the below to create a table in JavaScript from an array...

    But I want something a bit different than what I am getting below.

    I want the ID to be 2 Rows high and on the far LEFT
    I then want ObsID, SppBova, COMMON_NAME, Tier to be to the right of the ID but all on row 1
    Then to the right of the ID and on the 2nd line I want GENUS, SPECIES, FedStatus, TaxaGrp

    Can I modify the below to do this or is there an easier way? I need to do this in JS

    var i;
    var out = "<table id=t02>";
    dojo.forEach(newarr, function (arr){
    out += "<tr><td>" +
    arr.id +
    "</td><td>" +
    arr.ObsID +
    "</td><td>" +
    arr.SppBova +
    "</td><td>" +
    arr.COMMON_NAME +
    "</td><td>" +
    arr.GENUS +
    "</td><td>" +
    arr.SPECIES +
    "</td><td>" +
    arr.Tier +
    "</td><td>" +
    arr.FedStatus +
    "</td><td>" +
    arr.TaxaGrp +
    "</td></tr>";
    });
    out += "</table>";
    document.getElementById("id02").innerHTML = out;
     
    jaykappy, Oct 22, 2015
    #1
    1. Advertisements

  2. jaykappy

    jaykappy

    Joined:
    Oct 18, 2015
    Messages:
    5
    Likes Received:
    0
    Tried something like this but its all messed up

    var i;
    var out = "<table id=t02>";
    dojo.forEach(newarr, function (arr){
    out += "<tr><td rowspan='2'>" +
    arr.COMMON_NAME +
    "</tr></td><tr><td rowspan='2'>" +
    arr.GENUS +
    "</td><td rowspan='2'>" +
    arr.SPECIES +
    "</td><td rowspan='2'>" +
    arr.Tier +
    "</td></tr><tr><td rowspan='2'>" +
    arr.FedStatus +
    "</td><td rowspan='2'>" +
    arr.TaxaGrp +
    "</td></tr>";
    });
    out += "</table>";
    document.getElementById("id02").innerHTML = out;
     
    jaykappy, Oct 23, 2015
    #2
    1. Advertisements

  3. jaykappy

    jaykappy

    Joined:
    Oct 18, 2015
    Messages:
    5
    Likes Received:
    0
    I did this and got the attached...getting closer....

    var i;
    var out = "<table id=t02>";
    dojo.forEach(newarr, function (arr){
    out += "<tr><th>CommonName</th><th>GENUS</th><th>SPECIES</th></tr>" +
    "<tr><td rowspan='2'>" + arr.COMMON_NAME + "</td>" +
    "<td rowspan='1'>" + arr.GENUS + "</td>" +
    "<td rowspan='1'>" + arr.SPECIES + "</td></tr>";
    });
    out += "</table>";
    document.getElementById("id02").innerHTML = out;

    }
     

    Attached Files:

    jaykappy, Oct 23, 2015
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.