重复表格元素

时间:2017-12-02 12:39:24

标签: javascript dom html-table

我在这里有Firebase存储的代码。

enter image description here

在执行此操作时,我会在表数据中重复。这是我的javascript代码。我在for循环中做了一些逻辑错误。



function gotMuch(dude, guy)
{
    var ex9 = dude.val();
    var sa9 = Object.keys(ex9);
    var s9 = sa9.length;
    console.log("Hello there" + s9 + "");

    var did = ex9.did;
    var dmark = ex9.dmark;
    var dname = ex9.dname;
    console.log(did);
    console.log(dmark);
    console.log(dname);

    var y = document.querySelectorAll(".subtable" + guy + "").length;
    console.log("Class length is" + y + "");

    var ytabl = document.querySelectorAll(".subtable" + guy + "");
    var yd1 = document.createElement("td");
    var yd2 = document.createElement("td");
    var yd3 = document.createElement("td");
    var space = document.createElement("br");
   
    for(var b = 0; b < y; b++)
    {
        var row = ytabl[b].insertRow(0);
        var cell1 = row.insertCell(0);
        var cell2 = row.insertCell(1);
        var cell3 = row.insertCell(2);
    
        cell1.innerHTML = did;
        cell2.innerHTML = dname;
        cell3.innerHTML = dmark;
    }
}
&#13;
&#13;
&#13;

0 个答案:

没有答案