您当前的位置:首页 > 计算机 > 编程开发 > JavaScript

js动态添加<tr>行数据

时间:12-09来源:作者:点击数:

动态添加<tr>行数据

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="js/jquery-1.4.js"></script>
	</head>

	<body>
		<div id="scrolldIV">
			<table id="checkboxTable">
				<tr>
					<th>
						<input type='checkbox' id="checkedAll" onclick="selected()" />
					</th>
					<th>
						<span id="cname">序号</span>
					</th>
					<th>
						<span id="name">批号</span>
					</th>
					<th>
						<span id="name">公证书编号</span>
					</th>
					<th>
						<span id="value">事项名称</span>
					</th>
					<th>
						<span id="appname">当事人</span>
					</th>

					<th>
						<span id="appname">受理时间</span>
					</th>
					<th>
						<span id="appname">备注</span>
					</th>
				</tr>

				<tr name="ajid">
					<td>
						<input type='checkbox' onclick='test()' class='listCheckbox' />
					</td>
					<td align="center">1</td>
					<td>PH666</td>
					<td>内民字第00637号</td>
					<td>事项03</td>
					<td>张三</td>
					<td class='zhsCla'>2020</td>
					<td>大傻逼</td>
				</tr>
				<tr name="ajid">
					<td>
						<input type='checkbox' onclick='test()' class='listCheckbox' />
					</td>
					<td align="center">1</td>
					<td>PH666</td>
					<td>内民字第00637号</td>
					<td>事项03</td>
					<td>张三</td>
					<td class='zhsCla'>2020</td>
					<td>大傻逼</td>
				</tr>

			</table>
		</div>
		<input name="提交归档" type="button" onclick="saveSj();" value="确定送卷" />
	</body>

	<script>
		//模拟后台提供的数据
		var A = ["BF2020NM49", "内民字第00705号", "事项00", "李四1", "2019", "赵云"]
		var B = ["BF2020NM50", "内民字第00706号", "事项01", "李四2", "2016", "李白"]
		var C = ["BF2020NM51", "内民字第00707号", "事项02", "李四3", "2018", "亚索"]
		var D = ["BF2020NM52", "内民字第00708号", "事项03", "李四4", "2017", "后裔"]
		var S = [A, B, C, D]
		var j = 0;

		function saveSj() {
			if($("#checkboxTable tr:gt(0)").length > 0) {
				for(var i = 0; i < S.length; i++) {
					j = j + 1;
					$tr = $("<tr id='count_" + j + "'>" +
						"<td>" +
						"<input type='checkbox'  value='" + j + "'  οnclick='test()' class='listCheckbox' />" +
						"</td>" +
						"<td align='center'>" + j + "</td>" +
						"<td>" + S[i][0] + "</td>" +
						"<td>" + S[i][1] + "</td>" +
						"<td>" + S[i][2] + "</td>" +
						"<td>" + S[i][3] + "</td>" +
						"<td>" + S[i][4] + "</td>" +
						"<td>" + S[i][5] + "</td>" +
						"</tr>");
					var div = document.getElementById('scrolldIV');
					$("#checkboxTable").append($tr);
				}
			}
		}
	</script>

</html>
在这里插入图片描述
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门