Home  >  Article  >  Web Front-end  >  How to display dynamic headers and columns using javascript_javascript skills

How to display dynamic headers and columns using javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:50:281397browse

The example in this article describes how to display dynamic table headers and columns using JavaScript. Share it with everyone for your reference. The details are as follows:

<!-- 
作者:恺哥
时间:2008-11-5
用途:测试动态表头与动态表列的展现
-->
<html>
<head>
<title>test</title>
</head>
<body>
<script language="javascript">
//初始化表列
var t_column = new Array("col_head");
for(var m=0;m<10;m++){
 t_column.push("col"+m);
}
//初始化表行
var t_row = new Array();
for(var m=0;m<5;m++){
 t_row.push("row"+m);
}
function p(o){
 document.writeln(o);
}
p("<table width=\"95%\" border=\"1\">");
p("<tr>");
for(var i=0;i<t_column.length;i++){
 p("<td>"+t_column[i]+"</td>");
}
p("</tr>");
for(var j=0;j<t_row.length;j++){
 p("<tr>");
  p("<td>"+t_row[j]+"</td>");
  for(var k=1;k<t_column.length;k++){
  p("<td>value"+k+"</td>");
  }
 p("</tr>");
}
p("</table>");
</script>
</body>
</html>

I hope this article will be helpful to everyone’s JavaScript programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn