需要一个HTML模板,用来做简单的表单数据录入

html-css09

需要一个HTML模板,用来做简单的表单数据录入,第1张

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模板。

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为文件名;后两句是将字符串写入文件和关闭输出流文件。

天幻可以用replace函数或者正则表达式都可以例子: CreateFile.asp //===================================================================== 下面举一个简单的例子介绍一下这种思路的简单实现方法。

建立数据库db.mdb【使用Access】, 创建标签表Tag,字段如下: 自动编号 标签名称(文本型) 标签说明(文本型) 标签内容(备注型) ID tagName tagDesc tagCon 1 $Top_Nav$ 顶部导航 具体内容 创建模版表Template,字段如下: ID(自动编号) tName(文本,模版名称) tPath(文本,模版文件路径) Path(文本,保存路径) 1 公司介绍 /Template/Company.html /Company.html 【本例只介绍简单的文件模版使用,而非多个样式的模版】

后台标签、模版的添加修改删除就不在这里说明了,注意:本例中标签使用$符号开头和结尾。 Company.html部分代码:……$Top_Nav$……$Sys_Top_News$……先使用Fso或者其他方式以文本方式读取这个文件的内容,然后使用正则表达式,找到标签,并替换相应的标签内容。

FSO读取详见“FSO文件、文件夹操作类”。 程序代码 '使用正则的处理标签的函数chxwei.com

Function ReplaceTags(ByVal sCon)

Dim objRegEx,Match,Matches

'建立正则表达式

Set objRegEx=New RegExp'查找内容objRegEx.Pattern="\$.*\$"

'忽略大小写

objRegEx.IgnoreCase=True'全局查找objRegEx.Global=True

Set Matches=objRegEx.Execute(sCon)

'循环替换已发现的匹配

For Each Match in Matches

sCon=Replace(sCon,Match.Value,ParseTag(Match.Value))NextSet Matches=Nothing

Set objRegEx=Nothing

ReplaceTags=sCon

End Function

'替换相应的标签内容chxwei.com

Function ParseTag(ByVal StrTag)

If Len(StrTag) = 0 Then Exit Function

ClsName=StrTagtmpTag=""If InStr(ClsName,"$Sys_")>0 Then '系统标签

Select Case ClsName

Case "$Sys_Top_News$" '最新文章信息

'中间读取数据库省略,循环读取数据赋值给tmpTagCase ElsetmpTag=""End SelectElse '自定义标签tmpTag=""Set RsT=Conn.Execute("Select tCon From TagList Where tName='"&className&"'")

If RsT.Eof Then

tmpTag=classNameElsetmpTag=RsT(0)End IfRsT.CloseSet RsT=NothingEnd IfParseTag=tmpTag

最后使用Fso把得到的内容按照模版保存的路径生成静态页面。