备份

 function generateHtml(arr) {
        var inputHtml = "<td><input class='danjia' type='text' value='0' /></td><td><input class='kucun' type='text' value='0' /></td>";
        var totalRows = 1;
        for (var k in arr) {
            totalRows *= arr[k].length;
        }
        var resultArr = new Array(totalRows), srcArr, rowSpan = 1;
        for (var i = arr.length - 1; i >= 0; i--) {
            srcArr = arr[i];
            var index = 0;
            for (var j = 0; j < totalRows ; j += rowSpan) {
                if (index == srcArr.length) {
                    index = 0;
                }
                var infoList = srcArr[index++].split(',');
                resultArr[j] = '<td rowspan="' + rowSpan + '" lang="' + infoList[0] + '">' + infoList[1] + "</td>" + (typeof resultArr[j] == "undefined" ? "" : resultArr[j]);
            }
            rowSpan *= srcArr.length;
        }
        var html = "";
        for (var j = 0; j < totalRows ; j++) {
            html += "<tr>" + resultArr[j] + inputHtml + "</tr>";
        }
        return html;
    }

 

posted @ 2016-09-09 10:46  真幻de现实  阅读(188)  评论(0编辑  收藏  举报