网站地图    收藏   

主页 > 前端 > css教程 >

table动态增加一行 - html/css语言栏目:html.css - 自

来源:自学PHP网    时间:2015-04-14 14:51 作者: 阅读:

[导读] %@ page language=java import=java.util.* pageEncoding=UTF-8%%String path = request.getContextPath();String basePath = request.getScheme()+://+request.getServerName()+:+reque......

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <base href="<%=basePath%>">
  <title>My JSP 'tableaddrow.jsp' starting page</title>
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">
  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  <meta http-equiv="description" content="This is my page">
  <!--
  <link rel="stylesheet" type="text/css" href="styles.css">
  -->
  <script type="text/javascript">
  function tableAddRow(tableName)
  {
   var row = tableName.insertRow(tableName.rows.length);  //行对象
   var i = tableName.rows.length - 2; //table原有的行数
   var col;  //列对象
 
   if(tableName==tableId)
   {
    col = row.insertCell(0);
    col.innerHTML = "<input type='text' size='1' />";
    col = row.insertCell(1);
    col.innerHTML = "<input type='text' size='1' />";
    col = row.insertCell(2);
    col.innerHTML = "<input type='text' size='1' />";
    col = row.insertCell(3);
    col.innerHTML = "<input type='text' size='1' />";
   }
  }
  </script>
</head>
<body>
  <input type=button value=增加行 onclick="tableAddRow(tableId);" />

  <table id="tableId">
   <tr bgcolor="#E1F0C4">
    <td>标号</td>
    <td>姓名</td>
    <td>性别</td>
    <td>年龄</td>
   </tr>
  </table>
</body>
</html>

作者“shuxiaomeng”
 

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论