用ASP+FSO生成JS文件
编程学习 2021-07-05 10:58www.dzhlxh.cn编程入门
代码如下:
<!--#include file="conn.asp"-->
<%
set js = server.CreateObject("ADODB.RecordSet")
sql="select top 10 * from article order by id desc"
set js = conn.Execute (Sql)
do while not js.eof
title=js("title")
addate=js("addate")
foolcat = foolcat + "<li><a href=""/"& js("id")&".htm"">" &title&" "&addate&"</a></li><br>"
js.movenext
loop
'生成JS文件
foolcat = "" + foolcat + ""
foolcat = "document.write('" & foolcat & "')"
FolderPath = Server.MapPath("./")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(FolderPath&"\top10.js")
fout.WriteLine foolcat
'关闭连接
fout.close
set fout = nothing
js.close
set js = nothing
conn.close
set conn=nothing
%>
<%
set js = server.CreateObject("ADODB.RecordSet")
sql="select top 10 * from article order by id desc"
set js = conn.Execute (Sql)
do while not js.eof
title=js("title")
addate=js("addate")
foolcat = foolcat + "<li><a href=""/"& js("id")&".htm"">" &title&" "&addate&"</a></li><br>"
js.movenext
loop
'生成JS文件
foolcat = "" + foolcat + ""
foolcat = "document.write('" & foolcat & "')"
FolderPath = Server.MapPath("./")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(FolderPath&"\top10.js")
fout.WriteLine foolcat
'关闭连接
fout.close
set fout = nothing
js.close
set js = nothing
conn.close
set conn=nothing
%>
上一篇:ASP动态生成的javascript表单验证代码
下一篇:把无限级分类生成数组