动态给TABLE中的每个单元格赋值 用json返回一个对象数组,然后动态创建表格,把json返回数组里面的内容添加到创建的动态表格里面去只要知道怎么得到某一个单元格的对象、任何把显示的内容放上去 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><head><script type="text/javascript"> function createTable(datas) { var table = document.createElement('table'); for (var rowIndex = datas.length - 1; rowIndex >= 0; rowIndex--) { var row = table.insertRow(); for (var colIndex = 0; colIndex < datas[rowIndex].length; colIndex++) { var col = document.createElement('td'); var textNode = document.createTextNode(datas[rowIndex][colIndex]); col.appendChild(textNode); row.appendChild(col); } } return table; } window.onload = function() { document.body.appendChild(createTable([[1, 2, 5], [2, 3, 4], [3, 4, 3]])); };</script></head><body></body></html> for(var i=0;i<data.orgList.length;i++){ var rows = objTable.insertRow(); for(var j=0;j<4;j++){ //只有四列 var cells = rows.insertCell(); cells.align = "center"; //如何赋值 : } } objTable.appendChild();数组的类型:{"orgList":[{"org": {"orgId":[42],"parentId":[0],"inactiveChildrenNum":[0],"res":["2"],"activeChildrenNum":[1],"orgName":["2"]}},{"org": {"orgId":[43],"parentId":[0],"inactiveChildrenNum":[0],"res":["3"],"activeChildrenNum":[1],"orgName":["3"]}},{"org": {"orgId":[47],"parentId":[0],"inactiveChildrenNum":[0],"res":["444"],"activeChildrenNum":[0],"orgName":["444"]}},{"org": {"orgId":[41],"parentId":[0],"inactiveChildrenNum":[0],"res":["1"],"activeChildrenNum":[1],"orgName":["1"]}}]} jsp:逐行删除每行对应的数据,为什么Servlet接不到值呢 修改web.xml文件问题 益智题 SSH如何对IP地址库进行读取??根据IP显示其地理位置? 困扰了几天的setInterval用了之后程序就报错,望高手来救命。。。 怎样在jsp中引用servlet里定义的参数? 乱马的问题~ Web站点中:怎么样在javabean中得到javabean本身的所在路径? 请教改变后台往界面传送数据的流程 刚建项目就报错 SSH项目中myeclipse不编译JSP,Java文件,不加载xml文件怎么办?? 急 重装系统完 安装独显安装不了~
<head>
<script type="text/javascript">
function createTable(datas) {
var table = document.createElement('table');
for (var rowIndex = datas.length - 1; rowIndex >= 0; rowIndex--) {
var row = table.insertRow();
for (var colIndex = 0; colIndex < datas[rowIndex].length; colIndex++) {
var col = document.createElement('td');
var textNode = document.createTextNode(datas[rowIndex][colIndex]);
col.appendChild(textNode);
row.appendChild(col);
}
}
return table;
} window.onload = function() {
document.body.appendChild(createTable([[1, 2, 5], [2, 3, 4], [3, 4, 3]]));
};</script>
</head>
<body>
</body>
</html>
for(var i=0;i<data.orgList.length;i++){
var rows = objTable.insertRow();
for(var j=0;j<4;j++){ //只有四列
var cells = rows.insertCell();
cells.align = "center";
//如何赋值 :
}
}
objTable.appendChild();数组的类型:
{"orgList":
[
{"org":
{"orgId":[42],"parentId":[0],"inactiveChildrenNum":[0],"res":["2"],"activeChildrenNum":[1],"orgName":["2"]}},
{"org":
{"orgId":[43],"parentId":[0],"inactiveChildrenNum":[0],"res":["3"],"activeChildrenNum":[1],"orgName":["3"]}},
{"org":
{"orgId":[47],"parentId":[0],"inactiveChildrenNum":[0],"res":["444"],"activeChildrenNum":[0],"orgName":["444"]}},
{"org":
{"orgId":[41],"parentId":[0],"inactiveChildrenNum":[0],"res":["1"],"activeChildrenNum":[1],"orgName":["1"]}}
]
}