求高手帮处理一下,谢谢!
以下是代码
<!--#include file="conn.asp"-->
<%
dim num:num =request.Form("num")&""
if num <>"" and isnumeric(num) then
num =cint(num)
dim i
dim fdesc,fqty,fprice,ftotal,no
for i=0 to num
fdesc=request.Form("fdesc"&i)&""
fqty=request.Form("fqty"&i)&""
fprice=request.Form("fprice"&i)&""
ftotal=request.Form("ftotal"&i)&""
no=request.Form("p_no")&""
if fdesc<>"" and fqty<>"" and ftotal<>"" and fprice<>""and isnumeric(ftotal) then'Âú×ãÒªÇóµÄÊý¾Ý²Å²åÈë
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from traffic", conn, 1, 3
rs.AddNew
rs("j_name")=(fdesc)
rs("j_idcode")=(fqty)
rs("j_mony")=(ftotal)
rs("j_shiyu")=(fprice)
rs("j_id")=(no)
rs.Update
rs.Close
end if
next
set rs=nothing
response.write "<script language='javascript'>alert('Ìí¼Ó³É¹¦£¡');"
response.write "window.location.href='admin_addtraffic.asp';</script>"
response.end
end if
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="698" border="0" cellspacing="1" cellpadding="0" class="tb" id="tlist">
<tr class="tit2" bgcolor="#00FFFF">
<td width="50" height="27">
<div align="center"></div>
<div align="center">id</div>
</td>
<td width="51" height="27">Ô±¹¤±àºÅ</td>
<td width="125" height="27">
<div align="center">Ô±¹¤ÐÕÃû</div>
</td>
<td width="266" height="27">
<div align="center">ÊÂÓÉ</div>
</td>
<td width="100" height="27">
<div align="center">½ð¶î</div>
</td>
<td width="99" height="27">
<div align="center">²Ù×÷
<input type="button" value="Ôö¼Ó" onClick="AddRecord();" name="button">
</div>
</td>
</tr>
<tr class="tit3">
<td colspan="7" height="2"> </td>
</tr>
<tr class="tit2">
<td colspan=7 height="2">
<input type="text" id="znum" value="0" name="znum"/>
</td>
</tr>
</table>
<script>
function AddRecord()
{
var num=0;
var row = tlist.insertRow(tlist.rows.length-2);
row.className='tit3';
var num= row.rowIndex;
var col = row.insertCell(0);
col.innerHTML = num
col = row.insertCell(1);
col.innerHTML = " <input type='text' name='fdesc' size=15 maxlength=20>";
col = row.insertCell(2);
col.innerHTML = " <input type='text' name='fqty' size=15 maxlength=20>";
col = row.insertCell(3);
col.innerHTML = " <input type='text' name='fprice' size=50 maxlength=50> ";
col = row.insertCell(4);
col.innerHTML = " <input type='text' name='ftotal' size=10 value='0' onkeyup='chtotal(this);'>";
col = row.insertCell(5);
col.innerHTML = " <input type='button' value='ɾ³ý' name='del' onclick='delrecord(this);'>";
num++;
}
function chtotal(e)
{
var obj=e.parentNode.parentNode;
var id=parseInt(obj.rowIndex)-1;
var ftotal=document.getElementsByName("ftotal")[id];
var delbutton=document.getElementsByName("del");
var newzum=0;
ftotal.value = ftotal.value;
for(var j=0;j <delbutton.length;j++)
{
newzum+=parseFloat(document.getElementsByName("ftotal")[j].value);
}
var znum= document.getElementById("znum");
znum.value=newzum;
}
function delrecord(obj)
{
obj.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode);
var delbutton=document.getElementsByName("del");
var newzum=0;
for(var j=0;j <delbutton.length;j++)
{
newzum+=parseFloat(document.getElementsByName("ftotal")[j].value);
}
var znum= document.getElementById("znum");
znum.value=newzum;
}
</script>
</body>
</html> |