动态创建DIV子项并添加/填充其值

时间:2017-05-07 15:18:12

标签: javascript html google-apps-script dynamic-content

请你帮忙使它工作,我试图在里面动态创建元素

并填充/添加到服务器函数将从数据库返回的DIV动态值的每个元素。也许有更好的方法来做到这一点?但我不知道其他任何选择。

这是代码,但它不起作用,控制台显示错误(Uncaught TypeError:无法设置属性'innerHTML'为null):

//This is the server side code that returns the data, it works fine, have checked it;
        function getReadyLine() {
            var rawData = sheetMAT.getRange(3, 2, sheetMAT.getLastRow() - 2, 5).getValues();
            for (var i = 0; i < rawData.length; i++) {
                if (rawData[i][3] === "A Ready Line" && rawData[i][4] === "ATY") {
                    temp1 = ' ' + data[i][0];
                    temp2.push(data[i][1], temp1);
                    dataReadyLine.push(temp2);
                    temp1 = '';
                    temp2 = [];
                }
            }
            return dataReadyLine;
        }

        //This is the client side code that should populate the innerHTML of the DIV template that is shown below;
        setInterval(function() {
            google.script.run.withSuccessHandler(function(data) {
                var temp3 = '';
                for (var i = 0; i < data.length; i++) {
                    temp3 = 'p' + data[i] + '/p';
                    document.getElementById("#item1").innerHTML = temp3;
                    temp3 = '';
                }
            }).getReadyLine();
        }, 10000);
    </script>

    //This is the DIV where I want to embed, display all the content/data returned from the server-side with the function getReadyLine();
    <div class="col-sm-3 col1">
        <h1 id="readyLine">Ready Line,
            <?= getCountReadyLine() ?> items</h1>
        <div class="item1" id="item1">
        </div>
    </div>

Print Screen

0 个答案:

没有答案