| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 505 人关注过本帖
标题:[原创]生成html的一个函数
只看楼主 加入收藏
belin2000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:975
专家分:194
注 册:2004-6-2
结帖率:0
收藏
 问题点数:0 回复次数:5 
[原创]生成html的一个函数
<%
'生成html的一个函数
function makehtml(path,filename,nr)
'path(为虚路径) 如 "../test" test为文件夹名
'filename 要生成的文件名 如首页 index
'nr 要生成的内容
'例子
'if(makehtml("test","index","basdfsdfasdasdfasdf")) then
'response.Write("生成成功")
'else
'response.Write("生成失败")
'end if
dim truepath,filen,fs,brray,i,pathname,st,st_one,msg
set fs=server.createobject("Scripting.FileSystemObject")
truepath=server.MapPath(path)
'是否要建立文件夹
brray=split(truepath,"\")
pathname=brray(0)&"\"&brray(1)
'response.Write(ubound(brray))
'response.End()
for i=1 to ubound(brray)
if not fs.FolderExists(pathname) then fs.CreateFolder(pathname)
if i+1<=ubound(brray) then pathname=pathname&"\"&brray(i+1)
next
'建立了要建立的文件夹
filen= truepath&"/"&filename&".htm"
if fs.fileExists(filen) then fs.deletefile(filen) '删除已经存在的文件
set st=fs.createtextfile(filen,true)
st_one=mid(nr,i,1)
for i=1 to len(nr)
st_one=mid(nr,i,1)
st.write(st_one)
next
set st=nothing
set fs=nothing
if err.number<>0 then
msg=false
else
msg=true
end if
makehtml=msg
end function
%>
搜索更多相关主题的帖子: 函数 html 
2005-08-09 17:52
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
收藏
得分:0 
楼主,发点静态分页和首页生成HTML的来啊

中国人的财富网:http://www..cn/
2005-08-09 17:54
belin2000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:975
专家分:194
注 册:2004-6-2
收藏
得分:0 
首页生成HTML
上面那个就是.

静态分页,我在研究更好的方法!

59ita点com(我就爱TA)
2005-08-10 09:20
belin2000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:975
专家分:194
注 册:2004-6-2
收藏
得分:0 
'生成分页
function pagesplit(pathname,sql,pages)
'pathname 路径和文件名
'sql语句
'pages 分页条数(每页有多少条记录)
dim path,filen,brray,i
brray=split(pathname)
filen=split(brray(ubound(brray)),".")(0)
for i=0 to ubound(brray)-1
path=path&brray(i)
next
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
dim psize,totalpage
psize=pages
totalpage=int(rs.recordcount/psize*-1)*-1
'response.Write(totalpage)
'response.End()
dim tt,filen,msg,shown
page=0
for page=0 to totalpage-1 '共分为 totalpage 页
rs.movefirst
rs.move(page*psize)
filen="index" '要生成的名称
shown=filen
tt=""
if page>0 then filen=filen&"_"&page
i=0
do while not rs.eof and i<psize
tt=tt&rs(0)&"<br>"
rs.movenext
i=i+1
loop
if int(totalpage)>1 then
tt=tt&"<a href ="&shown&".htm> 第一页 </a>"
if page=0 then tt=tt&"<a href="&shown&"_"&page+1&".htm> 下页 </a>"
if int(page)=int(totalpage) then tt=tt&"<a href="&shown&"_"&page-1&".htm> 上页 </a>"
if page>0 and int(page)<int(totalpage-1) then
if page-1>0 then
tt=tt&" <a href="&shown&"_"&page-1&".htm> 上页 </a> "
else
tt=tt&"<a href="& shown&".htm> 上页 </a>"
end if
tt=tt&" <a href="&shown&"_"&page+1&".htm> 下页 </a>"
end if
tt=tt&"<a href="& shown&"_"&totalpage-1&".htm>末页</a>"
end if
if(makehtml(path,filen,tt)) then
msg=msg&"生成分页成功"&filen&".htm<br>"
else
msg=msg&"生成分页失败"&filen&".htm<br>"
end if
next
response.Write(msg)
set rs=nothing
enf function

59ita点com(我就爱TA)
2005-08-10 10:57
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
收藏
得分:0 
不错,我回去研究一下

中国人的财富网:http://www..cn/
2005-08-10 11:05
belin2000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:975
专家分:194
注 册:2004-6-2
收藏
得分:0 
有空再写一个长文章分页(可在编辑器分页和安长度分页)

59ita点com(我就爱TA)
2005-08-10 11:08
快速回复:[原创]生成html的一个函数
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011463 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved