- <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <htmlxmlns="http://www.w3.org/1999/xhtml">
- <head>
- <metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
- <scriptlanguage="JavaScript"type="text/javascript">
- functionaddnew()
- {
- c=prompt("请输入内容!","");//列
- if(c==null)
- {
- returnfalse;
- }
- elseif(c.replace(/^\s+|\s+$/g,"")=="")
- {
- alert("输入内容为空!");
- returnfalse;
- }
- //alert(c);
- }
- addnew();
- varr;//定义行
- setrc(3,c);//调用指定行列输出表格,根据内容数组维来指定几行几列
- functionsetrc(r,c){//指定行列输出表格函数
- document.write("<tableborder=1>")
- for(i=1;i<=r;i++)
- {
- document.write("<tr>")
- for(j=1;j<=c;j++)
- document.write("<td>"+Math.pow(j,i))//输出数组
- document.write("</tr>")
- }
- document.write("</table>")
- }
- //setrc(3,2);
- </script>
- </body>
- <title>无标题文档</title>
- </head>
- <body>
- </body>
- </html>
本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/813003