现在有一个ASP文件有两个表单表单一和表单一
表单一
日期 商品代码 商品名称 产销国 数量 单位 单价 总价 操作
表单二
日期 商品代码 商品名称 产销国 数量 单位 单价 总价 操作
想实现功能是:我在表单二不断添加数据后读入表单一中,表单二要向表单一添加多条数据,都要在表单一上显示出来,然后将表单一上的数据一次性保存到数据库中。
我现在只能向表单一添加一条数据,如果再添加一条之前的那条就被新添加的数据替换掉了。
[QUOTE]<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style>
.listTitle{position:relative; float:left; width:100px; height:18px; line-height:18px;font-size:12px;}
.list{position:relative; float:left; width:100px; height:18px; line-height:18px; font-size:12px;}
.textBox{border:1px solid #CCCCCC; width:100%;}
</style>
</head>
<body>
<div style="margin-top:20px; border:1px solid #CCCCCC;height:0px;">
<form name="form1" method="post" action="">
<div id="listTitle">
<div class="list">日期</div>
<div class="list">商品代码</div>
<div class="list">商品名称</div>
<div class="list">产销国</div>
<div class="list">数量</div>
<div class="list">单位</div>
<div class="list">单价</div>
<div class="list">总价</div>
<div class="list">操作</div>
</div>
<DIV id="newDataList">
</DIV>
</form>
</DIV>
<DIV style="margin-top:20px; border:1px solid #CCCCCC;height:0px;">
<form name="form2" method="post" action="">
<div class="list">日期</div>
<div class="list">商品代码</div>
<div class="list">商品名称</div>
<div class="list">产销国</div>
<div class="list">数量</div>
<div class="list">单位</div>
<div class="list">单价</div>
<div class="list">总价</div>
<div class="list">操作</div>
<div class="list"><input type="text" class="textBox" name="input_text_1"></div>
<div class="list"><input type="text" class="textBox" name="input_text_2"></div>
<div class="list"><input type="text" class="textBox" name="input_text_3"></div>
<div class="list"><input type="text" class="textBox" name="input_text_4"></div>
<div class="list"><input type="text" class="textBox" name="input_text_5"></div>
<div class="list"><input type="text" class="textBox" name="input_text_6"></div>
<div class="list"><input type="text" class="textBox" name="input_text_7"></div>
<div class="list"><input type="text" class="textBox" name="input_text_8"></div>
<div class="list"><input type="button" name="button" value="添加" onClick="addData();"></div>
</form>
</DIV>
</body>
</html>
<script language="javascript">
var listNo = 0
function addData(){
var input_text_1 = document.form2.input_text_1.value;
var input_text_2 = document.form2.input_text_2.value;
var input_text_3 = document.form2.input_text_3.value;
var input_text_4 = document.form2.input_text_4.value;
var input_text_5 = document.form2.input_text_5.value;
var input_text_6 = document.form2.input_text_6.value;
var input_text_7 = document.form2.input_text_7.value;
var input_text_8 = document.form2.input_text_8.value;
var newDivObj_id = "dataList_"+ listNo;
var newDataStr = "<div class=\"list\"><input type=\"hidden\" name=\"p_Date\" value=\""+ input_text_1 +"\">"+ input_text_1 +"<\/div>"+
"<div class=\"list\"><input type=\"hidden\" name=\"p_Code\" value=\""+ input_text_2 +"\">"+ input_text_2 +"<\/div>"+
"<div class=\"list\"><input type=\"hidden\" name=\"p_Name\" value=\""+ input_text_3 +"\">"+ input_text_3 +"<\/div>"+
"<div class=\"list\"><input type=\"hidden\" name=\"p_ToCountry\" value=\""+ input_text_4 +"\">"+ input_text_4 +"<\/div>"+
"<div class=\"list\"><input type=\"hidden\" name=\"p_Counts\" value=\""+ input_text_5 +"\">"+ input_text_5 +"<\/div>"+
"<div class=\"list\"><input type=\"hidden\" name=\"p_Unit\" value=\""+ input_text_6 +"\">"+ input_text_6 +"<\/div>"+
"<div class=\"list\"><input type=\"hidden\" name=\"p_Price\" value=\""+ input_text_7 +"\">"+ input_text_7 +"<\/div>"+
"<div class=\"list\"><input type=\"hidden\" name=\"p_SumPrice\" value=\""+ input_text_8 +"\">"+ input_text_8 +"<\/div>"+
"<div class=\"list\"><input type=\"button\" name=\"button\" value=\"删除\" onclick=\"deleteList('"+ newDivObj_id +"');\"><\/div>";
var newDivObj = document.createElement('DIV');
newDivObj.id = newDivObj_id;
newDivObj.name = newDivObj_id;
newDivObj.style.height = "0px";
newDivObj.innerHTML = newDataStr;
document.getElementById("newDataList").appendChild(newDivObj);
listNo ++;
}
function deleteList(Obj){
with (document.getElementById("newDataList")){
try{
removeChild(document.getElementById(Obj));
}catch(e){}
}
}
</script>[/QUOTE]