动态生成表单并提交到数据库中的问题?

stone100 2003-06-21 10:14:56
由数据库的参数表中动态生成表单如:
数据库表 table

流水号 物品号 物品名称
id ncSubjectNo ncSubjectName
1 100010 苹果
2 100020 梨
3 100030 香蕉


动态生成一个asp表单页如取物品号不大于100020的水果记录,然后填写购买个数:

苹果:(文本框)个数
梨 :(文本框)个数

填妥后点击"提交"按钮,提交购买记录,提交的记录在数据库中也是一条一条的如:

流水号 物品号 购买件数
id ncSubjectNo Number
1 100010 10
2 100020 100

请个位高手给指教一下吧。
...全文
86 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
tfhui928 2003-07-25
  • 打赏
  • 举报
回复
中的"S1"和"T1"指的是哪两个数?

应该是两个文本框(text)的名字。
tfhui928 2003-07-25
  • 打赏
  • 举报
回复
判断提交的数量心须为数字呢

用函数isNumberic()
如:if isNumeric(lab_computers) then
stone100 2003-07-25
  • 打赏
  • 举报
回复
up
stone100 2003-07-17
  • 打赏
  • 举报
回复
up
stone100 2003-06-25
  • 打赏
  • 举报
回复
什么东西???
试问如何在提交时动态判断提交的数量心须为数字呢?
basil 2003-06-22
  • 打赏
  • 举报
回复
首先确定物品号必须为整形的,不是整形的要处理一下,
假设为整形
test1.asp
<form action="" method="" name="">
<%set rs=server.createobject("adodb.recordset")
sql="select * from table where ncSubjectNo<=100020"
rs.open sql,dbconn,1,1
do while not rs.eof
%>
<tr>
<td><%=rs(1)%></td>
<td><input name="S<%=rs(0)%>" type="text" value="<%=rs(1)%>"></td>
<td><input name="T<%=rs(0)%>" type="text"></td>
</tr>
<%rs.movenext
loop%>
<tr>
<td><button type="submit">提交</button>
</tr>
test2.asp
做一个循环,循环次数可由前一页面的rs.recordcount通过hidden传过来
sql="insert table1 values(1,'"&request.form("S1")&"','"&request.form("T1")&"')"
qiangdeng 2003-06-22
  • 打赏
  • 举报
回复
<%



if request.form("title")="" then

response.write "錯誤提示﹕請輸入文章標題!"

response.end

end if

if request.form("txtcontent")="" then

response.write "錯誤提示﹕請輸入文章內容!"

response.end

end if



if request.form("author")="" then

response.write "錯誤提示﹕請輸入作者信息"

response.end

end if



theyear=request.form("d1")

themonth=request.form("d2")

zongjuan=request.form("d3")

zongqikanhao=request.form("d4")

qikanhao=request.form("d5")

ver=trim(request("ver"))

title=request.form("title")

author=request("author")

author_type=request.form("author_type")

abstract=request.form("abstract")

key=request.form("key")

new_sort=request.form("new_sort")

zhushi=request.form("zhushi")

cankao=request.form("cankao")

image=request.form("image")

content=request.form("txtcontent")

set rs=server.createobject("adodb.recordset")

sql="select * from article"

rs.open sql,conn,1,3

rs.addnew

rs("a_year")=theyear

rs("a_month")=themonth

rs("qikanhao")=qikanhao

rs("zongqikanhao")=zongqikanhao

rs("zongjuan")=zongjuan

rs("title")=title

rs("author")=author

rs("authortype")=author_type

rs("content")=content

rs("image")=image

rs("cankao")=cankao

rs("zhushi")=zhushi

rs("keyword")=key

rs("abstract")=abstract

rs("catalog_code")=new_sort

rs("ver")=ver

rs("a_time")=now

rs.update

rs.close

set rs=nothing

%>

stone100 2003-06-22
  • 打赏
  • 举报
回复
老兄,请问你:
sql="insert table1 values(1,'"&request.form("S1")&"','"&request.form("T1")&"')"
中的"S1"和"T1"指的是哪两个数??
Jaron 2003-06-21
  • 打赏
  • 举报
回复
select * from 表 where ncSubjectNo<=100020
ncSubjectNo 要是数值型。

28,391

社区成员

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

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