加入收藏
<a href="javascript:window.external.AddFavorite('http://127.0.0.1/', '校务管理系统V1.0')" title="单击进入即可" hidefocus="true" ><span class="STYLE3">加入收藏</span></a>
设为首页
<a href="#" onClick="this.style.behavior='url(#default#homepage)';this.setHomePage
('http://127.0.0.1/');"title="单击进入即可" hidefocus="true"><span class="STYLE3">设为首页</span></a>
读文件
<%
dim fso
dim fs
dim gg
set fso=server.CreateObject("scripting.filesystemobject")
'如果路径下有gg.txt 文件
if fso.fileexists(server.mappath("gg.asp")) then
set fs=fso.opentextfile(server.mappath("gg.asp"))
gg=fs.readall()
'如果没有gg.txt文件
else
gg="欢迎访问本网站,感谢您的大力支持"
end if
%>
<marquee direction="up" scrolldelay="30" scrollamount="1" id="gg" onMouseOver="gg.stop();" onMouseOut="gg.start();">
<%=gg%>
</marquee>
写文件
<%
'写文件
dim ggtxt1
ggtxt1=request("ggnr")
if ggtxt1<>"" then
dim fso1
dim fo1
set fso1=server.CreateObject("scripting.filesystemobject")
set fo1=fso1.opentextfile(server.mappath("gg.asp"),2)
fo1.write(ggtxt1)
fo1.close
set fo1=nothing
set fso1=nothing
response.Redirect("main.asp")
end if
%>
动态显示第一页/上一页/下一页/末一页
<a href="dis.asp?pn=1">第一页</a>
<a href="dis.asp?pn=<%=pn-1%>">上一页</a>
<a href="dis.asp?pn=<%=pn+1%>">下一页</a>
<a href="dis.asp?pn=<%=rs.pagecount%>">末一页</a>
动态显示页码 [i]
<%
for i=1 to rs.pagecount
%>
<a href="dis.asp?pn=<%=i%>">[<%=i%>]</a>
<%
next
%>
检索数据判断页号正确性
1.链接数据库
<!--#include file="dbcon.asp"-->
2.检索出指定条件的数据,并降序显示
<%
dim rs
dim i
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from jl order by 学号 desc",con,1,3,1
设置页面中数据的个数
rs.pagesize=5
判断页号是否为空""/数字isnumeric(pn)/是否大于0小于页面总数
dim pn
pn=request("pn")
if pn="" then
pn=1
elseif isnumeric(pn)=false then
pn=1
elseif clng(pn)<=0 or clng(pn)>rs.pagecount then
pn=1
end if
确定当前页面
rs.absolutepage=pn
%>
浏览窗口的URL等于列表中的页号,动态链接
<script language="javascript">
function changeym()
{
window.location="dis.asp?pn="+document.form1.menuym.value;
}
</script>
<form id="form1" name="form1" method="post" action="">
<select name="menuym" id="menuym" onchange="changeym();"> 动态改变列表中的页号
如果列表中的页号等于1到页面总数中的任意页面,当前被选择
<%
for i=1 to rs.pagecount
if clng(pn)=i then
%>
<option value="<%=i%>" selected="selected">第<%=i%>页</option>
否则不被选择
<%else%>
<option value="<%=i%>">第<%=i%>页</option>
<%
end if
next
%>
</select>
</form>
对浏览窗口的页号进行保护
<%
dim pn
pn=request("pn")
if pn="" then
pn=1
elseif isnumeric(pn)=false then
pn=1
elseif clng(pn)<=0 or clng(pn)>rs.pagecount then
pn=1
end if
rs.absolutepage=pn
%>
根据表中记录在单选按钮中显示
<%
if rs("学号")="男" then
%>
<input name="xb" type="radio" value="男" checked="checked" />
男
<input type="radio" name="xb" value="女" />
女
<%else%>
<input type="radio" name="xb" value="男" />
男
<input type="radio" name="xb" value="女" checked="checked" />
女
<%end if%>
不要滚动条
让竖条没有:
<body style=`overflow:-Scroll;overflow-y:hidden`>
</body>
让横条没有:
<body style=`overflow:-Scroll;overflow-x:hidden`>
</body>
两个都去掉?更简单了
<body scroll="no">
</body>
固定背景图
在<head>和</head>之间加入如下代码:
<style type="text/css">
<!--
BODY
{
BACKGROUND-IMAGE: url(frames.gif);
BACKGROUND-REPEAT: no-repeat;
BACKGROUND-position: center;
BACKGROUND-ATTACHMENT: fixed;
}
-->
</style>
如何在同一页面设置不同文字链接效果的样式
<HTML><HEAD><TITLE>如何在同一页面设置不同文字链接效果的样式</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
a:hover { font-size: 9pt; color: #FF0000; text-decoration: underline}
a:link { font-size: 9pt; color: #006699; text-decoration: underline}
a:visited { font-size: 9pt; color: #006699; text-decoration: underline}
a:active { font-size: 9pt; color: #FF0000; text-decoration: none}
a.r1:hover { font-size: 9pt; color: #FF0000; text-decoration: underline overline}
a.r1:link { font-size: 9pt; color: #000000; text-decoration: underline overline}
a.r1:visited { font-size: 9pt; color: #99CC00; text-decoration: underline overline}
a.r1:active { font-size: 9pt; color: #000000; text-decoration: underline overline}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<a href="#">下划线链接 </a>
<p></p>
<a href="#" class="r1">双下划线链接</a>
</BODY>
</HTML>
补充说明:
a:hover 表示鼠标划过时的样式.
a:link 表示链接的样式.
a:active 表示当前活动连接的样式.
a:visited 表示已经访问过的连接的样式.
导入到EXCEL数据库
<!--#include file="dbcon.asp"-->
<%
dim excelfile,tbname
excelfile="drxydata.xls" '指定excel文件名
tbname="Sheet1" '指定excel表名
Dim Driver,DBPath
Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Excel Driver (*.xls)};Readonly=0;"
DBPath = "DBQ=" & Server.MapPath(excelfile)
conn.Open Driver & DBPath
set rs= Server.CreateObject("adodb.recordset")
'写入excel部分
sql="select * from ["& tbname &"$]"
rs.Open sql,conn,3,3
dim rs1
set rs1=server.CreateObject("adodb.recordset")
rs1.open "select 姓名,性别,身份证号,培训课程,电话,地址,交费,欠费,操作员,报名时间,修改员,修改时间 from xybm,kcb where kcb.课程号=xybm.课程号",con,1,3,1
for i= 1 to rs1.recordcount
rs.addnew
rs("姓名")=rs1("姓名")
rs("性别")=rs1("性别")
rs("身份证号")=rs1("身份证号")
rs("培训课程")=rs1("培训课程")
rs("电话")=rs1("电话")
rs("地址")=rs1("地址")
rs("交费")=rs1("交费")
rs("欠费")=rs1("欠费")
rs("操作员")=rs1("操作员")
rs("报名时间")=rs1("报名时间")
rs("修改员")=rs1("修改员")
rs("修改时间")=rs1("修改时间")
rs1.movenext
next
rs1.close
set rs1=nothing
con.close
set con=nothing
rs.update
%>
<script language="javascript">
alert("数据已成功导入到EXCEL")
</script>
<%
response.End
%>
自动编号
<!--#include file="dbcon.asp"-->
<%
dim rs
dim i
set rs=server.CreateObject("adodb.recordset")
rs.open "select 报名号 from xybm",con,1,3,1
'编号
dim ybh
ybh=""
for i=1 to rs.recordcount
ybh=ybh+rs("报名号")+"*"
rs.movenext
next
rs.close
set rs=nothing
con.close
set con=nothing
for i=1 to 9999
if i<10 then
dqbh="000"+trim(cstr(i))
elseif i<100 then
dqbh="00"+trim(cstr(i))
elseif i<1000 then
dqbh="0"+trim(cstr(i))
else
dqbh=trim(cstr(i))
end if
dqbh="2010"+dqbh
if instr(ybh,dqbh)=0 then
exit for
end if
next
response.Write("<br>"+dqbh)
%>
照片显示
<%
dim fso
set fso=server.CreateObject("scripting.filesystemobject")
if fso.fileexists(server.MapPath("img/2010xy/"+cstr(rs("报名号"))+".jpg"))=true then
%>
<td width="90" height="120" rowspan="3">
<div align="center"><img src="img/2010xy/<%=rs("报名号")%>.jpg" width="90" height="120" /></div></td>
<%
else
%>
<td width="90" height="120" rowspan="3"><div align="center"><img src="photo/wu.jpg" width="90" height="120" /></div></td>
<%end if
set fso=nothing
%>
按回车相当于按Tab键
</script>
<script language="javascript" for="document" event="onkeydown">
if(event.keyCode==13 && event.srcElement.type!='textarea' && event.srcElement.type!='submit' && event.srcElement.type!='reset' && event.srcElement.type!='button')
{
event.keyCode=9;
}
</script>
固定字号大小
<style type="text/css">
<!--
body {font-size:9pt}
td {font-size:9pt}
-->
</style>
框架的显示和隐藏(1)
1.
<script language="javascript">
function changedis(n)
{
var i;
for(i=1;i<=3;i++) 'i取值范围,有几个要单击的就取几
if(i==n)
{
if(document.getElementById("erji"+n).style.display=="none")
document.getElementById("erji"+n).style.display="block";
else
document.getElementById("erji"+n).style.display="none";
}
else
{
document.getElementById("erji"+i).style.display="none";
}
}
</script>
'数字动态替换
2.在单击的单元格内输入 onclick="changedis(1);"
3.在隐藏的单元格内输入 id="erji1" style="display:none;"
框架的显示和隐藏(2)
1.
<script language="javascript">
function dischange()
{
if(document.getElementById("lh").style.display=="block")
{
document.getElementById("lh").style.display="none";
document.getElementById("gqh").innerHTML="显示";
}
else
{
document.getElementById("lh").style.display="block";
document.getElementById("gqh").innerHTML="隐藏";
}
}
</script>
2.
<span id="gqh<%=i%>" style="color:#ff0000; cursor:hand;" onclick="dissrc('lh<%=i%>','gqh<%=i%>');">显示详细信息</span>
<table width="600" border="1" align="center" cellpadding="0" cellspacing="0" id="lh<%=i%>" style="display:none;">
注释:<%=i%> 是动态显示多条需要显示的信息 for i= 1 to rs.recordcont
框架网页类型
<script language="javascript">
function changesrc(mc)
{
document.getElementById("main").src=mc;
}
</script>
<iframe id="main" width="700" height="840" frameborder="0"></iframe>
style="cursor:hand" onclick="changesrc('modpwd.asp')"
文件上传
1.顶部输入下面代码,此代码必不可少
<%
Response.Buffer = True '建立缓存
Server.ScriptTimeOut=9999999 '定义超期时间
On Error Resume Next
%>
2.在<body>下输入 可上传文件的类型
ExtName = "jpg,gif,png,txt,rar,zip,doc" '允许的上传文件扩展名
SavePath = "xyphoto "文件路径:
<%
ExtName = "jpg,gif,png,txt,rar,zip,doc" '允许的上传文件扩展名
SavePath = "xyphoto" '文件保存路径
If Right(SavePath,1)<>"/" Then SavePath=SavePath&"/" '在目录后加(/)
CheckAndCreateFolder(SavePath)
UpLoadAll_a = Request.TotalBytes '取得客户端全部内容
If(UpLoadAll_a>0) Then
Set UploadStream_c = Server.CreateObject("ADODB.Stream")'建立对象
UploadStream_c.Type = 1
UploadStream_c.Open
UploadStream_c.Write Request.BinaryRead(UpLoadAll_a)
UploadStream_c.Position = 0
FormDataAll_d = UploadStream_c.Read
CrLf_e = chrB(13)&chrB(10)
FormStart_f = InStrB(FormDataAll_d,CrLf_e)
FormEnd_g = InStrB(FormStart_f+1,FormDataAll_d,CrLf_e)
Set FormStream_h = Server.Createobject("ADODB.Stream")
FormStream_h.Type = 1
FormStream_h.Open
UploadStream_c.Position = FormStart_f + 1
UploadStream_c.CopyTo FormStream_h,FormEnd_g-FormStart_f-3
FormStream_h.Position = 0
FormStream_h.Type = 2
FormStream_h.CharSet = "GB2312"
FormStreamText_i = FormStream_h.Readtext
FormStream_h.Close
FileName_j = Mid(FormStreamText_i,InstrRev(FormStreamText_i,"\")+1,FormEnd_g)
If(CheckFileExt(FileName_j,ExtName)) Then
SaveFile = Server.MapPath(SavePath & FileName_j)
If Err Then
'Response.Write "文件上传: <span style=""color:red;"">文件上传出错!</span> <a href=""" & Request.ServerVariables("URL") &""">重新上传文件</a><br />"
%>
<script language="javascript">
alert("文件上传出错,重新上传");
window.location="wjsc.asp"
</script>
<%
Err.Clear
Else
SaveFile = CheckFileExists(SaveFile)
k=Instrb(FormDataAll_d,CrLf_e&CrLf_e)+4
l=Instrb(k+1,FormDataAll_d,leftB(FormDataAll_d,FormStart_f-1))-k-2
FormStream_h.Type=1
FormStream_h.Open
UploadStream_c.Position=k-1
UploadStream_c.CopyTo FormStream_h,l
FormStream_h.SaveToFile SaveFile,2
SaveFileName = Mid(SaveFile,InstrRev(SaveFile,"\")+1)
' Response.write "文件上传: <span style=""color:red;"">" & SaveFileName & " </span>文件上传成功! <a href=""" & Request.ServerVariables("URL") &""">继续上传文件</a><br />"
%>
<script language="javascript">
alert("恭喜您,文件上传成功");
window.location="kbwy.asp";
</script>
<%
End If
Else
'Response.write "文件上传: <span style=""color:red;"">文件格式不正确!</span> <a href=""" & Request.ServerVariables("URL") &""">重新上传文件</a><br />"
%>
<script language="javascript">
alert("文件格式不正确,请确认后重新上传");
window.location="wjsc.asp";
</script>
<%
End If
Else
%>
<script language="Javascript">
<!--
function ValidInput()
{
if(document.upform.upfile.value=="")
{
alert("请选择上传文件!")
document.upform.upfile.focus()
return false
}
return true
}
// -->
</script>
3.
在表单中把 类型该为文本类型 file
<input type="file" name="textfield" size="45" />
4.结束
<%
End if
Set FormStream_h = Nothing
UploadStream.Close
Set UploadStream = Nothing
%>
5.上传在</html>后面输入
<%
'判断文件类型是否合格
Function CheckFileExt(FileName,ExtName) '文件名,允许上传文件类型
FileType = ExtName
FileType = Split(FileType,",")
For i = 0 To Ubound(FileType)
If LCase(Right(FileName,3)) = LCase(FileType(i)) then
CheckFileExt = True
Exit Function
Else
CheckFileExt = False
End if
Next
End Function
'检查上传文件夹是否存在,不存在则创建文件夹
Function CheckAndCreateFolder(FolderName)
fldr = Server.Mappath(FolderName)
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(fldr) Then
fso.CreateFolder(fldr)
End If
Set fso = Nothing
End Function
'检查文件是否存在,重命名存在文件
Function CheckFileExists(FileName)
Set fso=Server.CreateObject("Scripting.FileSystemObject")
If fso.FileExists(SaveFile) Then
i=1
msg=True
Do While msg
CheckFileExists = Replace(SaveFile,Right(SaveFile,4),"_" & i & Right(SaveFile,4))
If not fso.FileExists(CheckFileExists) Then
msg=False
End If
i=i+1
Loop
Else
CheckFileExists = FileName
End If
Set fso=Nothing
End Function
%>
6.在表单中输入 method="post" action="" onsubmit="return ValidInput()" enctype="multipart/form-data"
<form id="form1" name="form1" method="post" action="" onsubmit="return ValidInput()" enctype="multipart/form-data">
整体删除
1.获取要删除的标记
<script language="javascript">
function addf()
{
document.getElementById("delf").checked="checked";
}
</script>
2.单击一个,即全部删除
<td width="120" height="30" style="cursor:hand"
onclick="window.location='qyzpsh.asp?addf=y';"><span
class="STYLE2">审核</span></td>
3.
<%
dim addf
addf=request("addf")
if addf="y" then
%>
<input name="delf" type="checkbox"
id="delf" value="<%=rs("企业名称")%>" checked="checked"
/>
<%
else
%>
<input name="delf" type="checkbox"
id="delf" value="<%=rs("企业名称")%>" />
<%
end if
%>
4.通过表单传到处理页面
<!--#include file="dbcon.JS"-->
<%
dim qyid
qyid=request("delf")
qyid=replace(qyid," ","") 把空格替换成 , 8 , 9 , 10 ,15
qyid=replace(qyid,",","','") '转化后成为: 8','9','10','15
qyid="('"+qyid+"')" '转化后成为: ('8','9','10','15')
response.Write(qyid)
if qyid<>"" then
dim rs
set rs=server.CreateObject("adodb.recordset")
rs.open "update qyzpinfo set 审核='通过' where 企业名称
in " & qyid,con,1,3,1
%>
<script language="javascript">
window.location="qyzpsh.asp?f=1";
</script>
<%
else
response.Redirect("qyzpsh.asp")
end if
con.close
set con=nothing
%>
5.接收返回来的信息
<%
dim f
f=request("f")
if f=1 then
%>
<script language="javascript">
alert("企业信息审核通过");
</script>
<%
end if
f=""
%>
照片上传
1.表单处理到
zlh_fw_save_upload.asp
2.在上传中处理 onClick="return mysub();"
<script language="javascript">
function mysub()
{
if(document.form1.file.value=="")
{
alert("请先上传您的照片!")
return false
}
else
{
zpsc.style.visibility="visible";
}
}
</script>
3.在表单中添加下面代码进行处理
<input name="filepath" type="hidden" id="filepath" value="img/" />
<input name="filelx" type="hidden" id="filelx" value="jpg" />
<input name="EditName" type="hidden" id="EditName" value="<%=EditName%>" />
<input name="FormName" type="hidden" id="FormName" value="<%=formName%>" />
<input name="act" type="hidden" id="act" value="uploadfile" />
4.在表单中添加如下代码:
method="post" action="zlh_fw_save_upload.asp" enctype="multipart/form-data"
5.如果下面显示当前照片的话 session("bmh")
<div align="center">
<%
dim fso1
set fso1=server.CreateObject("scripting.filesystemobject")
if fso1.fileexists(server.MapPath("img/2010xy/" & session("bmh") & ".jpg"))=true then
%>
<img src="img/2010xy/<%=session("bmh")%>.jpg" width="90" height="120" border="1"/>
<%else%>
<img src="img/2010xy/wu.jpg" width="90" height="120" border="1"/>
<%end if%>
</div>