动态提交列表框中的数据

stiwin 2004-12-15 03:53:25
大家帮我看看这样的页怎么怎么做

http://211.147.235.59/test.html


freshking@163.com
...全文
164 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
friendlyFour 2004-12-17
  • 打赏
  • 举报
回复
忘了给你这个javascript的函数了
function IsPos(str){
var i,strlength,tempchar;

str=CStr(str);
if(str=="") return false;
if(parseInt(str)==0) return false;
strlength=str.length;
for(i=0;i<strlength;i++){
tempchar=str.substring(i,i+1);
if(!(tempchar==0||tempchar==1||tempchar==2||tempchar==3||tempchar==4||tempchar==5||tempchar==6||tempchar==7||tempchar==8||tempchar==9)){
return false;
}

}
return true;
}
还有就是,在函数function GetGoodsNum()中,做想if(IsPos(delNum.value==false))这个的判断了。
friendlyFour 2004-12-17
  • 打赏
  • 举报
回复
给的分太少了,我可以费了好的的力气才写完并加测试。一下为源代码:
<!-- #include file ="../includes/conn.asp" --> <!--这是我的conn-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>在线销售</title>
<SCRIPT language=javaScript src="../includec/check.js"></SCRIPT>
</head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function GetDelNum(inti){
var delNum,addNum,sumPrice,intj;
delNum=eval("document.all.frm1.txtGoods_Nums"+inti);
if(IsPos(delNum.value==false)){
alert("购买数量不符合要求!");
delNum.focus();
delNum.select();
return false;
}
var intTemp=delNum.value-1;
if(IsPos(intTemp)==false){
if(intTemp==1){
delNum.value=intTemp
return true;
}
else{
alert("购买数量不符合要求!");
delNum.focus();
delNum.select();
return false;
}
}
delNum.value=intTemp;
sumPrice=0;
intj=0;
var fltPrice,intGoods_Nums;
for(i=1;i<document.all.frm1.hidRecordset.value;i++){

fltPrice=eval("document.all.frm1.hidPrice"+i);
intGoods_Nums=eval("document.all.frm1.txtGoods_Nums"+i);

sumPrice=sumPrice+(fltPrice.value)*(intGoods_Nums.value);
if(intGoods_Nums.value==0){
sumPrice=sumPrice-(fltPrice.value)*(intGoods_Nums.value);
}
//alert(intGoods_Nums.value);
}
document.all.frm1.txtSumPrice.value=sumPrice;
}
function GetGoodsNum(inti,intValue){
sumPrice=0;
intj=0;
var fltPrice,intGoods_Nums;
for(i=1;i<document.all.frm1.hidRecordset.value;i++){

fltPrice=eval("document.all.frm1.hidPrice"+i);
intGoods_Nums=eval("document.all.frm1.txtGoods_Nums"+i);

sumPrice=sumPrice+(fltPrice.value)*(intGoods_Nums.value);

document.all.frm1.txtSumPrice.value=sumPrice;
}
}
//-->
</SCRIPT>
<body>
<form name="frm1" method="post" action="">
<table width="100%" border="0">
<tr>
<td width="6%">ID</td>
<td width="41%">名称</td>
<td width="12%">点数</td>
<td width="8%">金额</td>
<td width="33%" align="center">数量</td>
</tr>
<%
'这是我的临时表,字段为goods_ID,goods_Name,goods_Numd(点数),goods_Nums(数量),goods_price(价格)
strSql="select * from Tb_goods where goods_delFlag=0 order by goods_ID"
rs.open strSql,conn,1,1
Dim inti
inti=1
if not rs.eof then
do while not rs.eof

%>
<tr>
<td><%=inti%></td>
<td><%=rs("goods_Name")%></td>
<td><%=rs("goods_Numd")%></td>
<td><%=rs("goods_price")%>
<INPUT TYPE="hidden" name="hidPrice<%=inti%>" value="<%=rs("goods_price")%>">
</td>
<td><table width="100%" border="0">
<tr>
<td width="12%"><input type="button" name="delNum" value="-" onclick="GetDelNum(<%=inti%>)"></td>
<td width="59%"><input name="txtGoods_Nums<%=inti%>" type="text" value="0" onchange="GetGoodsNum(<%=inti%>,this.value)"></td>
<td width="29%"><input type="button" name="addNum" value="+" onclick="GetaddNum()"></td>
</tr>
</table></td>
</tr>
<%
inti=inti+1
rs.movenext
loop
end if
rs.close
%>
<INPUT TYPE="hidden" name="hidRecordset" value="<%=(inti)%>">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td>总金额</td>
<td><input name="txtSumPrice" type="text" value="0">
元</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit3" value="购买"></td>
<td><INPUT TYPE="reset"></td>
<td> </td>
</tr>
</table>
<p><font color="#FF0000">上面全是动态的.</font></p>
<p><font color="#FF0000">所有商品都有一个ID. 按购买后.要知道用户购买了一张"商品A" 点卡,二张"商品C"
.</font></p>
<p><font color="#FF0000">也就是说有ID=1 一张,ID=3 的二张.后台数据库记录这些信息.</font></p>
</form>
</body>
</html>
<!--
一点不足:
当数量为一个的时候,无法实现减为零
没有时间完成添加的那部分,你参考一下减的方式,做好了。
-->
stiwin 2004-12-16
  • 打赏
  • 举报
回复
up
friendlyFour 2004-12-16
  • 打赏
  • 举报
回复
你参考一下网上算你能买多大的楼房的网页,应该对你有帮助。我在sina.com.cn上看到过。我对这个挺感兴趣的,我没事的时候坐一下。^_^
stiwin 2004-12-15
  • 打赏
  • 举报
回复
动态按+号,-号数字变化同一行数据改变.总金额改变 ...

提交后怎么知道哪一项的数据改变.
梅雪香 2004-12-15
  • 打赏
  • 举报
回复
你觉得哪里难做?

87,919

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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