如何用asp生成静态html页面??

本文介绍了一个使用ASP编写的动态菜单生成脚本。该脚本能够从数据库中读取菜单信息并递归地生成多级菜单结构,适用于网站导航栏的快速搭建。通过调整SQL查询条件,可以灵活控制显示的菜单项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<%  
  dim   str  
  function   menu(id)  
  set   rs=server.CreateObject("adodb.recordset")  
  sql="select   *   from   menu   where   id1="&id&"   order   by   url,id"  
  rs.open   sql,conn,1,1  
  str=str+"<table   border='0'   cellspacing='0'   cellpadding='0'>"+chr(13)  
  i=1  
  while   not   rs.eof  
  ChildCount=conn.execute("select   count(*)   from   menu   where   id1="&rs("id"))(0)  
  if   ChildCount=0   then  
  if   i=rs.recordcount   then  
  menutype="file1"  
  else  
  menutype="file"  
  end   if  
  menuname="<a   href='"&rs("url")&"'   target='_blank'>"&rs("menuname")&"</a>"  
    
  else  
  if   i=rs.recordcount   then  
  menutype="menu3"  
  listtype="list1"  
  &rs("id")&"','b"&rs("id")&"');"  
  else  
  menutype="menu1"  
  listtype="list"  
  &rs("id")&"','b"&rs("id")&"');"  
  end   if  
  menuname=rs("menuname")  
  end   if  
  str=str+"<tr><td   id='b"&rs("id")&"'   class='"&menutype&"'"&onmouseup&">"&menuname&"</td></tr>"+chr(13)  
  if   ChildCount>0   then  
  str=str+"<tr   id='a"&rs("id")&"'   style='display:none'><td   class='"&listtype&"'>"+chr(13)  
  menu(rs("id"))  
  str=str+"</td></tr>"+chr(13)  
  end   if  
  rs.movenext  
  i=i+1  
  wend  
  str=str+"</table>"+chr(13)  
  rs.close  
  set   rs=nothing  
  end   function  
    
  menu(0)  
    
  set   fso=server.CreateObject("scripting.filesystemobject")  
  set   f1=fso.opentextfile(server.MapPath("demo.htm"),2,true)  
  f1.write("<!DOCTYPE   HTML   PUBLIC   '-//W3C//DTD   HTML   4.01   Transitional//EN'   'http://www.w3.org/TR/html4/loose.dtd'>")  
  f1.write("<html>")  
  f1.write("<head>")  
  f1.write("<meta   http-equiv='Content-Type'   content='text/html;   charset=gb2312'>")  
  f1.write("<title>哈哈~~~!这回速度超快了吧?</title>")  
  f1.write("<meta   name='keywords'   content='asp2004,树,菜单,无限级'>")  
  f1.write("<meta   name='author'   content='小灰,quxiaohui_0@163.com'>")  
  f1.write("<link   href='style.css'   rel='stylesheet'   type='text/css'>")  
  f1.write("<script   language='javascript'   src='function.js'></script>")  
  f1.write("</head>")  
  f1.write("<body>")  
  f1.write("<a   href='http://asp2004.net'   target='_blank'>http://asp2004.net</a>提供最新下载《<a   href='menu.asp'>管理</a>》<br/>")  
    
  f1.write(str)  
    
  f1.write("</body>")  
  f1.write("</html>")  
  f1.close  
  set   fso=nothing  
    
  response.Redirect("demo.htm")  
  %>  
­
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值