又一个运行不了的例程,请各位帮帮忙!!
两个asp程序,一个名为respond.asp,另一个asp7b.asp,先运行respond.asp,可ie总是说最后一行的代码出错,请各位帮忙看看。谢谢!!
respond.asp
**************************************************************************
<%
Dim user
Dim flag
Dim pwd
Dim say
Response.buffer = true '开启缓冲页面功能
Response.ContentType = "text/html"
Response.Charset = "gb2312"
user = Request.Form("username")
pwd = Request.Form("password")
say = Request.QueryString("say")
%>
<form method = "POST" action = "asp7b.asp">
<p>用户名:<input type = "text" name = "username" size = "12"><br>
口 令: <input type = "password" name = "password" size = "12"><br>
<input type = "submit" value = " 提交 " name = "B1">
<input type = "reset" value = " 取消 " name = "B2">
</p>
</form>
<%
If say = 1 Then
Response.Write"欢迎光临!"
End If
If say > 1 Then
Response.Write"欢迎再次光临!"
End If
If user = "Jliu" and pwd = "hello" Then
Response.Expires = 1 '设置该页面在浏览器的缓冲中存储1分钟后过期。
flag = 1
Else If user = "guest" and pwd = "guest" Then
Response.Expires = 0 '使缓存的页面立即过期。
Response.Clear '清空存储在缓存中的页面
flag = 2
Else If user = "vip" and pwd = "vip" Then
Response.Write "欢迎VIP光临Jliu 的ASP网站"
flag = 3
Else
flag = 0
Response.End '立即停止脚本处理,并将缓存中的页面输出
End If
Response.write "<p><a href='asp7b.asp?flag="&flag&"'>动态网页设计 Response 对象 </a></p>" '将变量flag的值传送给asp7b.asp
%>
**************************************************************************
asp7b.asp
**************************************************************************
<%
Dim say
say = Request.QueryString("flag")
select case say
case "1"
Response.Redirect "respond.asp?say=1"
case "2"
Response.Redirect "respond.asp?say=2"
case "3"
Response.Redirect "respond.asp?say=3"
case "0"
Response.Redirect "respond.asp?say=0"
End Select
%>
**************************************************************************
问题点数:100、回复次数:9Top
1 楼ChinaOk(农村表哥)回复于 2002-04-13 07:39:28 得分 0
Response.Write "欢迎VIP光临Jliu 的ASP网站"
flag = 3
Else
flag = 0
Response.End '立即停止脚本处理,并将缓存中的页面输出
End If
end if '加入
end if '加入
再我上面写的地方加入两个end if 就好了
注意 if then else end if的配对Top
2 楼hmbory(玻璃心)回复于 2002-04-13 08:25:03 得分 30
要不你就elseif中间不要用空格分开!纯属于语法错误:)Top
3 楼tripofdream(梦之旅)回复于 2002-04-13 08:52:56 得分 0
else if -->ElseIFTop
4 楼zcflion(吃大白菜的鸟--菜鸟)回复于 2002-04-13 09:20:08 得分 10
else if -->ElseIF
是语法出错,没大问题!Top
5 楼marist(我想学编程)回复于 2002-04-13 21:51:55 得分 0
加入了两个end if, else if--->elseif
可是ie指出第二个end if出错,怎么办????
Top
6 楼simpleease(沉思)回复于 2002-04-13 22:09:33 得分 0
应该将下面语句放在程序第一行:
<%Response.buffer = true%>
这是asp的语法要求Top
7 楼tripofdream(梦之旅)回复于 2002-04-13 22:16:24 得分 0
不需要加end ifTop
8 楼marist(我想学编程)回复于 2002-04-13 22:24:10 得分 0
去掉新添加的end if,程序可以执行,但是asp7b.asp的功能无法实现。
书上解释该程序可以演示设置页面缓存后出现的不同效果。可是asp7b.asp显示的是空白页面。
另:为什么不用加上end if?if和end if不需要一一对应吗?Top
9 楼tripofdream(梦之旅)回复于 2002-04-14 10:23:14 得分 60
ElseIf的用法:
If condition Then
[statements]
[ElseIf condition-n Then
[elseifstatements]] . . .
[Else
[elsestatements]]
End If
运行respond.asp时,由于request.querystring("say")的值为空,所以
If say = 1 Then
Response.Write"欢迎光临!"
End If
If say > 1 Then
Response.Write"欢迎再次光临!"
End If
这两个判断的内容都不会被执行;
由于user和pwd没有传回值,最后一个判断将会进入这个分支:
Else
flag = 0
Response.End '立即停止脚本处理,并将缓存中的页面输出
则
Response.write "<p><a href='asp7b.asp?flag="&flag&"'>动态网页设计 Response 对象 </a></p>" '将变量flag的值传送给asp7b.asp
这一句就不会执行.
从respond.asp提交到asp7b.asp时,Request.QueryString("flag")="",所以什么也不执行,就是一片空白了.Top




