如何添加输入行?

yin7huang 2010-02-22 06:00:22
我想实现如下的功能!怎么实现,谢谢!
比如我有一行输入框:比如有姓名、班级、年龄。我输完这一行后,我想在这一行的后面有一个“再添加”的按钮,点击“再添加”按钮后,在其下又多出一行输入框,内容还是姓名、班级、年龄,再点击“再添加”...........
这样怎么实现!谢谢!

还有,如果实现了上面的功能后,我又如何保存?我想每输入的一条信息保存为一条记录,不想让输入的所有信息保存在一条记录里面!
...全文
81 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
街头小贩 2010-02-23
  • 打赏
  • 举报
回复
用DOM复制元素!插入到复制元素的后面
ender129 2010-02-23
  • 打赏
  • 举报
回复

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ssgc_add.aspx.vb" Inherits="admin_ssgc_add" EnableViewState="true"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="none"/>
<title>本月大中型养殖场拜访记录</title>
<link rel="stylesheet" href="Calendar/global.css" type="text/css" />
<link rel="stylesheet" href="Calendar/ru_share.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="images/test.css" />
<style type="text/css">
<!--
.STYLE1 {
font-size: 18px;
font-weight: bold;
}
.STYLE2 {
color: #FFFF00;
font-size: 16px;
}
-->
</style>
</head>
<script type="text/javascript" src="Calendar/bglib.js"></script>
<script type="text/javascript" src="Calendar/shadow.js"></script>
<script type="text/javascript" src="Calendar/container.js"></script>
<script type="text/javascript" src="Calendar/resizer.js"></script>
<script type="text/javascript" src="Calendar/window.js"></script>
<script type="text/javascript" src="Calendar/form.js"></script>
<script type="text/javascript" src="Calendar/datepicker.js"></script>
<script type="text/javascript" src="Calendar/button.js"></script>
<body>
<script language="javascript">
function InsertRow(id,n){
var i
var tbl=document.getElementById("Table1");
rows=tbl.rows.length;

if (rows>20) return false;
//添加一行
var row=tbl.insertRow(-1);

//添加n列
for(i=1;i<=n;i++){
var cell = row.insertCell(-1);
cell.setAttribute("className","forumRow"); //只有IE这个傻B会认这个属性,其余浏览器会忽略这个属性而认下面的那个属性
cell.setAttribute("class","forumRow");
cell.setAttribute("align","center");

if (i==1){
var sTmp="'TD"+id+rows+"_8'";
}
else {
var sTmp="'TD"+id+rows+"_"+(i-1)+"'";
}
sTmp="<input id="+sTmp+" name="+sTmp+" type='text' style='width:98%' value="+sTmp+" />";
cell.innerHTML=sTmp;
}
}
</script>
<form id="form1" name="FORM1" method="post" action="5tijiao.asp?act=add">
<table border="0" align="center" cellpadding="1" cellspacing="1" class="tableBorder">
<tr>
<th height="20" colspan="8" align="center"><font color="#FFFF00">当前位置:</font>  本月大中型养殖场拜访记录</th>
</tr>
<tr>
<td height="25" colspan="8" align="right" class="forumRow">

<input type="button" name="button" value="点击添加一行" id="1" onClick="InsertRow(1,8)">
</td>
</tr>
<tr>
<td colspan="8" valign="top"><table width="100%" align="center" cellpadding="1" cellspacing="1" id="Table1">
<tr>
<td width="12%" align="center" class="forumRowHighlight">拜访日期</td>
<td width="12%" align="center" class="forumRowHighlight">养殖厂名称</td>
<td width="12%" align="center" class="forumRowHighlight">负责人</td>
<td width="12%" align="center" class="forumRowHighlight">电话</td>
<td width="12%" align="center" class="forumRowHighlight">地址</td>
<td width="12%" align="center" class="forumRowHighlight">养殖量</td>
<td width="12%" align="center" class="forumRowHighlight">主要合作厂家</td>
<td align="center" class="forumRowHighlight">合作意向</td>
</tr>
<tr>
<td align="center" class="forumRow">
<input type="text" name="TD11_8" style="width:98%">
</td>
<td align="center" class="forumRow">
<input type="text" name="TD11_1" style="width:98%">
</td>
<td align="center" class="forumRow">
<input name="TD11_2" type="text" style="width:98%" value="">
</td>
<td align="center" class="forumRow">
<input type="text" name="TD11_3" style="width:98%">
</td>
<td align="center" class="forumRow">
<input type="text" name="TD11_4" style="width:98%">
</td>
<td align="center" class="forumRow">
<input type="text" name="TD11_5" style="width:98%">
</td>
<td align="center" class="forumRow">
<input type="text" name="TD11_6" style="width:98%">
</td>
<td align="center" class="forumRow">
<input type="text" name="TD11_7" style="width:98%">
</td>
</tr>
</table></td>
</tr>
<tr>
<td height="81" colspan="8" align="left" class="forumRow"> 注:1. 母猪100头、育肥猪300头、肉鸡5000只、蛋鸡10000只、奶牛100头<br>
<span style="padding-left:30px">以上为大中型养殖场。</span><br>
<span style="padding-left:27px">2. 合作意向栏填: A. 同意用  B. 协商待定  C. 拒绝</span><br></td>
</tr>
<tr>
<td align="center" colspan="8" width="100%" height="20" class="forumRowHighlight">
<input type="submit" name="button2" id="button" value="保存数据">
</td>
</tr>
</table>

</form>
</body>
</html>

自己研究吧 这是类似的 跟你说的一样

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧