|
%
dim strdir
if request.QueryString("strdir")="" then
strdir=server.MapPath("question")
else
strdir=request.QueryString("strdir")
end if
dim myfo
set myfo=server.CreateObject("scripting.filesystemobject")
dim myfolder
set myfolder=myfo.getfolder(strdir)
dim Item,i,j
i=1
%>
<%for each item in myfolder.files%>
<form action="" method="post" name="form1">
<table width="100%" border="0">
<td width="10%">
<tr><td>问题<%=i%>:</td><td width="90%"><font color="#0000FF"><%response.write(replace(item.name,".txt",""))%></font></td>
<td width="9%"><% response.Write "<a href='modify.asp?strFile="&item.name&"'>修改</a>"&" "%></td>
</tr>
<% Dim FileObject '声明一个filesystemobject对象实例
Set FileObject=Server.CreateObject("Scripting.FileSystemObject")
Dim SourceFile '声明源文件和目标文件变量
SourceFile=Server.MapPath("question/"&item.name&"")
dim tf
set tf=FileObject.opentextfile(SourceFile)
j=1
do while not tf.atendofstream '读取文件
'下面通过表单和声明变量逐行读取题目和选项
%>
<tr><td>选项<%=j%>:<input type="radio" name="radiobutton<%=i%>" value="<%=j%>" />
</td>
<td><%Response.write tf.readline%></td> <%j=j+1%><%loop%>
</tr>
</td><%i=i+1%>
</table>
<% next%>
<label>
<input type="submit" name="Submit" value="提交" />
</label>
</form>
<%
dim radiobutton,n
n=1
radiobutton=request.Form("radiobutton"&i)
dim fobject
set fobject=server.CreateObject("scripting.filesystemobject")
dim textfile
set textfile=fileobject.opentextfile("d:\asp\答案.txt",8,true)
textfile.writeline("答案是:") & radiobutton
n=n+1
next n
textfile.close
%> |
|