HTML做个数据录入的模板。如下参考:
1、首先新建一个html,点击<body></body>中间,先填入表格内容:
2.内容可根据要求编写,示例代码如下:
<table>
<p style="text-align:center ">功课表</p>
<tr>
<th>语文</th>
<td>7:00-7:40</td>
<td>7:50-8:30</td>
</tr>
<tr>
<th>数学</th>
<td>7:00-7:40</td>
<td>7:50-8:30</td>
</tr>
<tr>
<th>英文</th>
<td>7:00-7:40</td>
<td>7:50-8:30</td>
</tr>
</table>
3.然后在<head></head>中间输入样式表的样式,如下图:
4.样式也可以根据个人需要设置,设置单元格的宽度高度,合并单元格,位置,颜色等,示例代码如下:
<style type="text/css">
body
{
width:340px
height:800px
}
table
{
border-collapse:collapse
}
th,td
{
width:100px
height:40px
border:1pxsolidblack
font-size:12px
text-align:center
}
</style>
5.注意,此代码“table的意思是表”的含义是将表边框合并为单个边框以合并相邻的更改。
6.预览结果如下图所示,一个制作简单的HTML模板。
<html>
<head>
<meta
http-equiv="Content-Language"
content="zh-cn">
<meta
http-equiv="Content-Type"
content="text/html
charset=gb2312">
<title>这是我的网页</title>
<meta
name="keywords"
content="这是我的网页">
<meta
name="description"
content="这是我的网页">
</head>
<body
bgcolor="#808080">
<div
style="position:
absolute
width:
450px
height:
550px
z-index:
1
left:
400px
top:
60px
padding-left:
60px
padding-right:
60px
padding-top:
90px
padding-bottom:
60px
background-color:
#FFFFFF"
id="layer1">
<p
align="center"><b>这是我的XXX页</b></p>
</body>
</html>
将上面的所有代码复制到记事本中,将记事本的后缀由txt更改为htm,这样打开后就会看到一张最简单的网页,如果需要多页,只需多复制几份即可,不同的内容需要你更改一下,如:我的网站首页,照片,个人资料,日志等...
1、ASP文件中的代码pencat=rs.Fields.Item("m_content").Value
pencat=replace(pencat,"t_title",n_title)
pencat=replace(pencat,"t_author",n_author)
pencat=replace(pencat,"t_content",n_content)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(server.mappath(fpath&"\" &fname))
fout.WriteLine pencat
fout.close
2、如下给出要生成的网页模板:
<html>
<head>
<meta http-equiv=""Content-Language"" content=""zh-cn"">
<meta http-equiv=""Content-Type"" content=""text/htmlcharset=gb2312"">
<meta name=""GENERATOR"" content=""Microsoft FrontPage 4.0"">
<meta name=""ProgId"" content=""FrontPage.Editor.Document"">
<title></title>
</head>
<body topmargin=""0"" leftmargin=""0"">
<table border=""0"" width=""760"" height=""100%"" background=""background.jpg"" >
<tr>
<td width=""752"" height=""10"" colspan=""3"">
<p align=""center"">t_title
</td>
</tr>
<tr>
<td width=""752"" height=""18"" colspan=""3"">
<div align=""center"">
</div>
<div align=""center"">
<font size=""2"">
作者:</font><font color=""#990000"">t_author</font>
<font size=""2"">
加入时间:</font><font color=""#990000"">t_date</font>
</div>
</td>
</tr>
<tr>
<td width=""15%"" height=""100%"" valign=""top"">
</td>
<td width=""70%"" height=""100%"" valign=""top"">
t_content
</td>
<td width=""15%"" height=""100%"" valign=""top"">
</td>
</tr>
</table>
</body>
</html>
3、解释
(1)pencat=rs.Fields.Item("m_content").Value
pencat为一个字符串变量。
rs.Fields.Item("m_content").Value就是如上2、网页模板的全部HTML字符
(2)pencat=replace(pencat,"t_title",n_title)
pencat=replace(pencat,"t_author",n_author)
pencat=replace(pencat,"t_content",n_content)
以上三句就是将字符串中的字串替换成为你所需要的内容,即ASP中动态获得的内容。
(3)Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(server.mappath(fpath&"\" &fname))
fout.WriteLine pencat
fout.close
以上为将刚刚组合所得的网页代码写入文件的过程。第一句定义fso文件,第二句创建输出流文件,其中fpath为你想要存储的文件的路径,fname为文件名;后两句是将字符串写入文件和关闭输出流文件。