asp for循环问题
<%ifsession("password")<>""then%><!--#includefile="inc/conn.asp"--><%ifrequest.querys...
<%if session("password")<>"" then%>
<!--#include file="inc/conn.asp"-->
<%if request.querystring("type")="news" then
dim i,j
num=request.form("number")
max=request.form("max")
set rs=Server.CreateObject("ADODB.Recordset")
for j=1 to num
for i=1 to max
if request("bj"&j&i)="--==请选择==--" then
response.write "<script language=JavaScript>" & chr(13) & "alert('请选择该学生所在班级');" & "history.back()" & "</script>"
Response.End
end if
if request("xh"&j&i)="" then
response.write "<script language=JavaScript>" & chr(13) & "alert('学号栏要全部填');" & "history.back()" & "</script>"
Response.End
end if
bj=Replace(Request.Form("bj"&j&i),"'","''")
xh=Replace(Request.Form("xh"&j&i),"'","''")
user=Replace(Request.Form("user"&j&i),"'","''")
kc=Replace(Request.Form("kc"&j&i),"'","''")
cj=Replace(Request.Form("cj"&j&i),"'","''")
xq=Replace(Request.Form("xq"&j&i),"'","''")
lx=Replace(Request.Form("lx"&j&i),"'","''")
sql="select * from bbs1 where bj='"&bj&"' and kc='"&kc&"' and xq='"&xq&"' and lx='"&lx&"' and xh='"&xh&"' and user='"&user&"'"
rs.open sql,conn,1,1
if not rs.eof then
response.write "<script language=JavaScript>" & chr(13) & "alert('您所添加的成绩部分已经存在!');" & "history.back()" & "</script>"
Response.End
end if
主要解释一下dim i,j
num=request.form("number")
max=request.form("max")
set rs=Server.CreateObject("ADODB.Recordset")
for j=1 to num
for i=1 to max是什么意思.还有("bj"&j&i)是什么意思?相加吗?)
(成绩管理系统的一段代码KC课程,CJ成绩)
谢谢! 展开
<!--#include file="inc/conn.asp"-->
<%if request.querystring("type")="news" then
dim i,j
num=request.form("number")
max=request.form("max")
set rs=Server.CreateObject("ADODB.Recordset")
for j=1 to num
for i=1 to max
if request("bj"&j&i)="--==请选择==--" then
response.write "<script language=JavaScript>" & chr(13) & "alert('请选择该学生所在班级');" & "history.back()" & "</script>"
Response.End
end if
if request("xh"&j&i)="" then
response.write "<script language=JavaScript>" & chr(13) & "alert('学号栏要全部填');" & "history.back()" & "</script>"
Response.End
end if
bj=Replace(Request.Form("bj"&j&i),"'","''")
xh=Replace(Request.Form("xh"&j&i),"'","''")
user=Replace(Request.Form("user"&j&i),"'","''")
kc=Replace(Request.Form("kc"&j&i),"'","''")
cj=Replace(Request.Form("cj"&j&i),"'","''")
xq=Replace(Request.Form("xq"&j&i),"'","''")
lx=Replace(Request.Form("lx"&j&i),"'","''")
sql="select * from bbs1 where bj='"&bj&"' and kc='"&kc&"' and xq='"&xq&"' and lx='"&lx&"' and xh='"&xh&"' and user='"&user&"'"
rs.open sql,conn,1,1
if not rs.eof then
response.write "<script language=JavaScript>" & chr(13) & "alert('您所添加的成绩部分已经存在!');" & "history.back()" & "</script>"
Response.End
end if
主要解释一下dim i,j
num=request.form("number")
max=request.form("max")
set rs=Server.CreateObject("ADODB.Recordset")
for j=1 to num
for i=1 to max是什么意思.还有("bj"&j&i)是什么意思?相加吗?)
(成绩管理系统的一段代码KC课程,CJ成绩)
谢谢! 展开
1个回答
展开全部
huizong=huizong+a&i错误你a1,a2,a3是一个变量名,变量名是不能用变量+变量形式得到,你这样只能得到a和i值字符累加,在这个程序里,你没有给变量a赋值 那么 huizong+a&i实际上相当于 huizong+"0"&i,得到结果应该是:0102030405。 如果此处你想要以循环方式得到总和,建议将a1,a2,a3转换成数组,给你个例子 <%dim a(5) a(1)=5 a(2)=10 a(3)=66 for i=1 to 5 huizong=huizong+a(i) next %>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询