1. 几个常用函数
Round(pi, 2) 四舍五入
FormatNumber(k,4) 把 k 格式化为带四位小数点的数。
eg. 如果k =20000则显示为20,000.00;如果把formatnumber(k,0)则为20,000
Replace(expression,find,replacewith) 返回一字符串,其中指定的子串已被另一个子串替换
Left(String,Length) 返回指定数目的从字符串的左边算起的字符串。
Split(expression[, delimiter[, count[, start]]]) 返回基于 0 的一维数组,其中包含指定数目的子字符串。
eg. 常用这个 Split(String,[delimiter]) 用delimiter(用于标识子字符串界限的字符)来划分字符串
Instr(String1,String2) 返回某字符串在另一字符串中第一次出现的位置
eg1. if instr(addation,密码配置表)<>0 then 说明存在
eg2. if instr(str,”AP”) >0 不好区分str = (AP,AP&AC),此时只要变为(’AP’,’AP&AC’),再用instr(str,”’AP’”)
2. 弹出窗口Pick值
function pickupSP(spdisid,pjnum,pdcode)
{
window.opener.<%=theForm%>.RefNum<%=Spid%>.value=spdisid;
window.opener.<%=theForm%>.LineS<%=Spid%>.value=pjnum;
window.opener.<%=theForm%>.kokey<%=Spid%>.value=pdcode;
window.close();
}
3. ASP控制图片显示的大小(等比例缩放)
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language=JavaScript>
<!--
var flag=false;
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= 164/112){
if(image.width>164){
ImgD.width=164;
ImgD.height=(image.height*164)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+x+image.height;
}
else{
if(image.height>112){
ImgD.height=112;
ImgD.width=(image.width*112)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+x+image.height;
}
}
}
//-->
</script>
</HEAD>
<BODY>
<a href=./img.jpg target=_blank><img src=./img.jpg
border=0 width=164 height=112 onload=javascript:DrawImage(this);></a>
</BODY>
</HTML>