top.asp
1、鼠标移动,改变背景:onmuserover="move(x)"
函数:
function move(t)
{
for(i=0;i<5;i++)
{
daohang.cells[i].className='top1';
daohang.cells[t].className='top2';
}
}//className 一定要大写
2、有框架top,left,main,点击top框架内的连接,同时改变left,main的页面
οnclick="urls(t)"
函数:
function urls(t)
{
window.parent.leftFrame.location.href="xxx"+tt+".asp";
window.parent.mainFrame.location.href="xxx"+tt+".asp";
}
left.asp
1. 有框架top,left,main,在left框架中提交表单,让表单结果在main框架显示:
<form name='form1' id='form1' mothed='post' action='xxx.asp' target='main'>
main.asp
1.在表单提交时动态加入一个input
函数:
function addinput()
{
act = document.createElement("input");//建立对象
act.type="hidden";//确定类型
act.value="del"; //付值
act.name="names";//命名
act.id="names";
form1.appendChild(act);//添加的要提交的form1中
}
2。全选复选框
onClick="All(this, 'checkname')"
函数:
function All(e,itemName)
{
var aa = document.getElementsByName(itemName);//选取页面的控件
aa[i].checked = e.checked //得到那个总控复选框的选中状态
}
//document.getElementsByName返回的是一个name数组:使用方法document.getElementsByName("abc")[0].value这样就得到了abc的值
//document.getElementByID返回的是一个name和ID的集合
//document.getElementsByTagName,document.formName.elements 这类方法所得到的结果也都是集合
3。删除时弹出确认框
οnclick="if(!confirm('确实要删除吗?')){return false;}"
//confirm弹出“是”和“否”,选“是”返回true,选“否"返回"false"
//form提交返回false,则不提交
4。判断提前10天生日提醒
函数:
function birthday(months,days)
{
dim tt
tt = FormatDatetime(year(date())&"-"&months&"-"&days)
da = datediff("d",tt,date())
if abs(da)<10 and da<0 then
response.Write("<font color='#ff0000'> 还有"&abs(da)&"天哦")
end if
}
//FormatDateTime(yyyy-mm-dd):格式化时间
//abs():取绝对值
//datediff("d",smalltime,bigtime)相差的单位一定加""
5.同页面insert.asp中用两个<iframe>,名字为main,right,从right 中点连接向main中送参数
<a href='xxx.asp?id=ssss' target='main'>连接</a>
在insert.asp中取得main中页面的值,tt =document.main.form1.xxx.value;
在insert.asp中点击按纽提交main中的表单,οnclick="javascript:documemt.main.form1.submit();"
6.改变td中背景颜色:
onMouseOver="this.bgColor='#xxxxxx'";onMouseOut="this.bgColor=''";
或者:onMouseOver="this.style.backgroundColor='#xxxxxx'" onMouseOut="this.style.backgroundColor=''"
当鼠标按下时变成另一种颜色,onMouseDown="this.bgColor='#ssssss'" onMouseOut和onMouseDown用不同的表现方式,如onMouseDown用backgroundColor,那么onMouseOut就用bgColor
二、数据库部分
sql2005存储过程建立:
create procedure [dbo].[test]
@CountryID int output,
@AreaID int output,
@CityID int output
as
begin
select @CountryID=count(*) from CountryInfo
select @AreaID = count(*) from AreaInfo
select @CityID = count(*) from CityInfo
end
页面中调用:
set cmd = server.createobject("adodb.command")
cmd.activeconnection = conn
cmd.commandtype = 4
cmd.commandtext = "test"
cmd.parater = true
cmd.parameters.append cmd.createparameter("@CountryID",4,2)
cmd.parameters.append cmd.createparameter("@AreaID",4,2)
cmd.parameters.append cmd.createparameter("@CityID",4,2)
cmd.execute
countrynum = cmd(0)
areanum = cmd(1)
citynum = cmd(2)
set cmd = nothing
2.导出Execl
原理:生成.csv 文件,安装了execl的客户端会自动下载
<% Set fso = CreateObject("Scripting.FileSystemObject")
filename=replace(now(),":","")
filename=replace(filename," ","")
filename=replace(filename,"-","")
Set MyFile = fso.OpenTextFile(server.MapPath("/upfile/"&filename&".csv"),2,True)
Myfile.Writeline("员工编号,姓名,分机号,Email,手机,生日")
set rs = server.CreateObject("adodb.recordset")
rs.open strsql,conn,1,1
while not rs.eof
Myfile.Writeline (rs("pid")&","&rs("ChineseName")&","&rs("DivTelePhone")&","&rs("Email")&","&rs("MobilePhone")&","&rs("bornmonth")&"/"&rs("bornday"))
rs.movenext
wend
rs.close
Myfile.close
response.redirect "/upfile/"&filename&".csv"
%>