为什么提交得不到想要的结果?

copico 2005-05-18 11:53:50
<!--#include file="conn.asp"-->


<body>
<p>
<%
dim sql
dim rs
sql="select * from course"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "还 没 有 任 何 被 选 课 题"
end if
%>

</p>
<%
dim id
%>
<form name="form1" method="post" action="tongguo2.asp?id=<%rs=("courseid")%>">

<table width="989" border="1">
<%
int i=0
do while not rs.eof and i<20
%>
<tr>

<td><%=rs("courseid")%></td>
<td><%=rs("cname")%></td>
<td><%=rs("xuan")%></td>
<%
id=rs("courseid")
%>
<td><input type="submit" name="Submit" value="提交"></td>
</tr>
<%
i=i+1
rs.movenext
loop
%>
</table>
</form>
<p> </p>
</body>
</html>

在course表里有courseid,cnamd,xuan
提交一个表到gonguo2.asp里面,可courseid的值为什么老是第一行的数据,不管我提交哪一行,courseid都是第一行的,为什么?
...全文
82 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
leo963258 2005-05-19
  • 打赏
  • 举报
回复
sql="select * from course where courseid="&kk&"" 你为什么要加两个引号.
大哥.20分要陪你通宵呀~~
copico 2005-05-19
  • 打赏
  • 举报
回复
是,是,是
这个我知道

哈,是onclick=后面不应该有“”吧?
去掉它就可以了
还有一个问题
这是tonguo2.asp的内容
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!--#include file="l_chkl.asp"-->
<%
dim kk
dim yy
dim sql
dim sqlsql
yy=request.Form("RadioGroup1")
kk=request("courseid")
set rs=server.CreateObject("adodb.recordset")
sql="select * from course where courseid="&kk&""
conn.execute(sql)
rs.open sql,conn,1,1

sqlsql="update course set xuan="&yy&" where courseid="&kk&""
conn.execute(sqlsql)
response.redirect "tongguo1.asp"
rs.close
set rs=nothing


%>

它说的我的courseid="&kk&"有问题,应该怎么写?
我看了它的数据库,courseid的字段是自动编号
leo963258 2005-05-19
  • 打赏
  • 举报
回复
kk=request("courseid")  老大,不是courseid 是kk=request("id") 
汗~~~
copico 2005-05-19
  • 打赏
  • 举报
回复
我在tongguo2.asp里写

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!--#include file="l_chkl.asp"-->
<%
dim kk
dim yy
dim sql
dim sqlsql
yy=request.Form("RadioGroup1")
kk=request("courseid")
response.Write(kk)


%>
可还是没有得到要的值呀
没有显示
卧_槽 2005-05-19
  • 打赏
  • 举报
回复
高手回了,我就不说了
leo963258 2005-05-19
  • 打赏
  • 举报
回复
<input type="button" name="button" value="提交" onclick="this.form.action="tongguo2.asp?id=<%rs=("courseid")%>"> 把提交按钮换了
leo963258 2005-05-19
  • 打赏
  • 举报
回复
<form name="form1" method="post">

<table width="989" border="1">
<%
int i=0
do while not rs.eof and i<20
%>
<tr>

<td><%=rs("courseid")%></td>
<td><%=rs("cname")%></td>
<td><%=rs("xuan")%></td>
<%
id=rs("courseid")
%>
<td><input type="button" name="button" value="提交" onclick="this.form.action="tongguo2.asp?id=<%rs=("courseid")%>">"></td>
</tr>
<%
i=i+1
rs.movenext
loop
%>
</table>
</form>
copico 2005-05-19
  • 打赏
  • 举报
回复
难道要循球form不成?
copico 2005-05-19
  • 打赏
  • 举报
回复
leo963258(读书之人)
应该怎么该?
leo963258 2005-05-19
  • 打赏
  • 举报
回复
id=<%rs=("courseid")%> 我的意思是,这个在循环外..显示数据当然是一样的
copico 2005-05-19
  • 打赏
  • 举报
回复
那应该怎么改
leo963258 2005-05-19
  • 打赏
  • 举报
回复
id=<%rs=("courseid")%>
这个也没有放在do while当然是第一行了

28,391

社区成员

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

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