浏览器大全:是一个提供流行浏览器教程、在线学习分享的学习平台!

ASP生成静态页面,学习CASE的用法,以及“权限”的一种控制方法

 

<form action="calscore.asp?action=do" method="post" name=form1> ... </form>

<!--#include file="connect.asp"-->
<% if session("logstatus")<>1 then %>
   <p align="center">
   <font size="5" ><b>你还没有登录,没有权利浏览本页,请先<a href="login.asp">登录</a>!</b></font></p>
<%
else
'读取login.htm附带的SubjectNo、StudentID及Name参数值
Subject=Request("Subject")
StudentID=Request("StudentID")
Name=Request("Name")

********  路径和文件的建立 ********************************************************************
'格式化日期
Function format(date)
            format=datepart("yyyy",date)&"年"&datepart("m",date)&"月"&datepart("d",date)&"日&nbsp;"&formatdatetime(date,vbshorttime)
End Function
dim fmonth,fday,fhour,fminute,fsecond
fmonth=month(date)
if len(month(date))<2 then fmonth="0"&month(date) end if
fday=day(date)
if len(day(date))<2 then fday="0"&day(date) end if
fhour=hour(now())
if len(hour(now()))<2 then fhour="0"&hour(now()) end if
fminute=minute(now())
if len(minute(now()))<2 then fminute="0"&minute(now()) end if
fsecond=second(now())
if len(second(now()))<2 then fsecond="0"&second(now()) end if
newspath=year(date)&fmonth&fday
newsurl=fhour&fminute&fsecond
putdate=format(now())

if request("action")="do" then

path=server.MapPath("kaoshi")  /.定义的一个文件
set fso=server.CreateObject("Scripting.FileSystemObject")
if fso.FolderExists(path)=false then
fso.CreateFolder(path)
end if
path=path&"/"&newspath
if fso.FolderExists(path)=false then
fso.CreateFolder(path)
end if
path=path&"/"&newsurl&".shtml"  /.生成SHTML页面

set ts=fso.OpenTextFile(path,2,true,-2)

******** 生成HTML页面  ***********************************************************************
ts.writeline"<html>"
ts.writeline"<head>"
ts.writeline"<title>"&name&""
ts.writeline","&subject&""
ts.writeline" - 成绩结果</title>"
ts.writeline"<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
ts.writeline"<link rel=""stylesheet"" href=""css.css"" type=""text/css"">"
ts.writeline"</head>"
ts.writeline""

ts.writeline"<body bgcolor=""#FFFFFF"" text=""#000000"">"
ts.writeline"<table width=""100%"">"
ts.writeline"<tr>"
ts.writeline"<td width=""100%"">"
ts.writeline"<h2>"
ts.writeline""&Name&""
ts.writeline",你的考试成绩如下表:</h2>"

dim score
score=0
sqlt="select * from 考题类型"
rst.open sqlt,conn,1,1
do while not rst.eof
tn=rst("id")
tname=rst("name")

ts.writeline"<b>"
ts.writeline""&tname&""
ts.writeline"</b><br><br>"

sql="Select * From "&Subject&" where 题目类型="&tn&" order by 题目序号"
rs.open sql,conn,2,2
while not rs.eof
 answer=rs("正确答案")
 select case rs("题目类型")
  case 1:
  selection=Request("No"&rs("题目序号"))
ts.writeline rs("题目序号")
ts.writeline"、"&selection&"<br>"
  case 2:
        selection=""
       for n=1 to 4
  if not Request("No"&rs("题目序号")&"-"&n)="" then
         selection=selection&Request("No"&rs("题目序号")&"-"&n)
  end if
        next
ts.writeline rs("题目序号")       
ts.writeline" 、"&selection&"<br>"
  case 3:    
        selection=Request(rs("选择项1"))
ts.writeline rs("题目序号")        
ts.writeline"、"&selection&"<br>"
        case else:
        selection=Request(rs("选择项1"))
ts.writeline rs("题目序号")
ts.writeline"、"        
ts.writeline"<font color=red>未确定评分规则!</font><br>"
ts.writeline""&selection&"<br>"
end select
if answer=selection then
  score=score+rs("本题分数")
end if
rs.movenext
wend

rs.close
ts.writeline"<br>"
rst.movenext
loop
'response.write score
'response.end

ts.writeline"<br>"
ts.writeline"<font color=red>评分:</font>"
ts.writeline""&score&""
ts.writeline"<br>"
ts.writeline"</td></tr></table>"
ts.writeline"</body>"
ts.writeline"</html>"
end if
%>




相关软件

2345加速浏览器官方版

2345加速浏览器官方版 | 56.2MB

2345加速浏览器官方版

新一代2345加速浏览器采用Chromium和IE双内核,主打极速与安全特性。基于Chromium深度定制,引入网页智能预加载技术,访问网页更快速..

QQ浏览器官方正式版

QQ浏览器官方正式版 | 49.67MB

QQ浏览器官方正式版

QQ浏览器秉承TT浏览器1-4系列方便易用的特点,但技术架构不同,交互和视觉表现也重新设计,采用Chromium内核+IE双内核,让浏览快速稳定...

百度浏览器最新版下载

百度浏览器最新版下载 | 13.3MB

百度浏览器最新版下载

q百度浏览器,是一款简洁轻快、智能懂你的浏览器。依靠百度强大的搜索平台,在满足用户浏览网页的基础上,它整合百度体系业务优势,带给用户更方便的浏览方式功能...

UC浏览器官方正式版

UC浏览器官方正式版 | 44.2MB

UC浏览器官方正式版

UC浏览器(UC Browser)是UC Mobile Limited在2004年8月开发的一款软件,分uc手机浏览器和uc浏览器电脑版。UC浏览器是全球使用量最大的第三方手机浏览器...

猎豹浏览器2022最新版下载

猎豹浏览器2022下载 | 45MB

猎豹浏览器2022最新版下载

猎豹安全浏览器对Chrome的Webkit内核进行了超过100项的技术优化,访问网页速度更快。其具有首创的智能切换引擎,动态选择内核匹配不同网页...

360安全浏览器官方版下载

360安全浏览器下载 | 21.4MB

360安全浏览器官方版下载

360安全浏览器拥有全国最大的恶意网址库,采用恶意网址拦截技术,可自动拦截挂马、欺诈、网银仿冒等恶意网址。独创沙箱技术,在隔离模式即使访问****也不会感染...