Javascript输出表格

 
  1. <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <htmlxmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
  5. <scriptlanguage="JavaScript"type="text/javascript">
  6. functionaddnew()
  7. {
  8. c=prompt("请输入内容!","");//列
  9. if(c==null)
  10. {
  11. returnfalse;
  12. }
  13. elseif(c.replace(/^\s+|\s+$/g,"")=="")
  14. {
  15. alert("输入内容为空!");
  16. returnfalse;
  17. }
  18. //alert(c);
  19. }
  20. addnew();
  21. varr;//定义行
  22. setrc(3,c);//调用指定行列输出表格,根据内容数组维来指定几行几列
  23. functionsetrc(r,c){//指定行列输出表格函数
  24. document.write("<tableborder=1>")
  25. for(i=1;i<=r;i++)
  26. {
  27. document.write("<tr>")
  28. for(j=1;j<=c;j++)
  29. document.write("<td>"+Math.pow(j,i))//输出数组
  30. document.write("</tr>")
  31. }
  32. document.write("</table>")
  33. }
  34. //setrc(3,2);
  35. </script>
  36. </body>
  37. <title>无标题文档</title>
  38. </head>
  39. <body>
  40. </body>
  41. </html>

本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/813003

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值