怎样让table表格中的数据进行批量添加

就是利用一个按钮实现,批量添加,有没有主要的代码,看一下,就是jsp页面的就行了

2个回答

 <script type="text/javascript">
        var learnnum=0;
        var learntemp=0;
        function addlearn(){
        var learntb = document.getElementById('learntb');
        learnnum  += 1;
        learntemp += 1;
        var learntr = document.createElement('tr');
        learntr.id = "learntr"+learnnum;

var learntd1 = document.createElement('td');
        learntd1.className = "td3";
        learntd1.innerHTML = "起止时间:";

        var learntd2 = document.createElement('td');
        learntd2.className ="td4";
        learntd2.innerHTML = "<input type='text' name='learntime"+ learnnum +"'/>";

        var learntd3 = document.createElement('td');
        learntd3.className = "td3";
        learntd3.innerHTML = "毕业学校:";

        var learntd4 = document.createElement('td');
        learntd4.className ="td4";
        learntd4.innerHTML = "<input type='text' name='endschool"+ learnnum +"'/>";

        var learntd5 = document.createElement('td');
        learntd5.className = "td3";
        learntd5.innerHTML = "所学专业:";

        var learntd6 = document.createElement('td');
        learntd6.className ="td4";
        learntd6.innerHTML = "<input type='text' name='professional"+ learnnum +"'/>";

        var learntd7 = document.createElement('td');
        learntd7.className = "td3";
        learntd7.innerHTML = "教育方式:";

        var learntd8 = document.createElement('td');
        learntd8.className ="td4";
        learntd8.innerHTML = "<input type='text' name='way"+ learnnum +"'/>";

learntr.appendChild(learntd1);
        learntr.appendChild(learntd2);
        learntr.appendChild(learntd3);
        learntr.appendChild(learntd4);
        learntr.appendChild(learntd5);
        learntr.appendChild(learntd6);
        learntr.appendChild(learntd7);
        learntr.appendChild(learntd8);
        learntb.appendChild(learntr);

//  var lt = document.getElementById('learntemp');
    //  lt.value = learntemp;

    }
</script>

<body onload="addlearn();">
    This is my JSP page. <br>

<table>
    <tbody id="learntb">
</tbody>

</table>
  </body>
ccl524
Sky灬Thunder 谢谢
5 年多之前 回复

声明一个数组,用push方法将每一串记录的对象加入数组中,将数组传给后台。

ccl524
Sky灬Thunder 谢谢
5 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐