网页制作的几个常用函数

1.几个常用函数
Round(pi, 2) '四舍五入


FormatNumber(k,4) '把 k 格式化为带四位小数点的数。

eg. 如果k =20000则显示为20,000.00;如果把formatnumber(k,0)则为20,000

Replace(e­xpression,find,replacewith) '返回一字符串,其中指定的子串已被另一个子串替换


Left(String,Length) '返回指定数目的从字符串的左边算起的字符串。


Split(e­xpression[, delimiter[, count[, start]]]) '返回基于 0 的一维数组,其中包含指定数目的子字符串。

eg. 常用这个 Split(String,[delimiter]) ' 用delimiter(用于标识子字符串界限的字符)来划分字符串

Instr(String1,String2) '返回某字符串在另一字符串中第一次出现的位置

eg. if instr(addation,"密码配置表")<>0 then '说明存在

2. 弹出窗口Pick值
function pickupSP(spdisid,pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjnum,pdcode)
{
    window.opener.<%=theForm%>.RefNum<%=Spid%>.value=spdisid;
    window.opener.<%=theForm%>.LineS<%=Spid%>.value=pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjhome.net" target="_blank">pjnum;
    window.opener.<%=theForm%>.kokey<%=Spid%>.value=pdcode;
    window.close();
}


3. ASP控制图片显示的大小(等比例缩放)


New Document







4. ASP中对数据库表的操作(Insert/Update/Delete),可使用事务处理,并支持多事务处理。
在ASP的数据库对象链接对象中,提供了一下属性:
BeginTrans 事务开始
CommitTrans 事务提交
RollbackTrans 事务回滚
<%
On Error Resume Next '错误发生后继续处理
'Asp中使用事务
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "course_dsn","course_user","course_password"
conn.begintrans '开始事务
sql="delete from user_info"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,3
if conn.errors.count>0 then '有错误发生
    conn.rollbacktrans '回滚
    set rs=nothing
    conn.close
    set conn=nothing
    response.write "交易失败,回滚至修改前的状态!"
    response.end
else
    conn.committrans '提交事务
    set rs=nothing
    conn.close
    set conn=nothing
    response.write "交易成功!"
    response.end
end if
%>


在ASP中,不提供事务的结束,BeginTrans只作用于自己的域,类似于变量声明一样,如果在函数体内BeginTrans,则事物只作用于本函数体,如果BeginTrans在函数体外,处于页面级,则事务的作用域从BeginTrans开始,到页面的结束均处于事务的管理状态下。
[本日志由 parno 于 2006-08-11 00:35 AM 编辑]
上一篇: 使用VBScript 中的类组织开发
下一篇: 怎样用 VB 编写 .DLL 动态链接库文件
文章来自:
引用通告: 查看所有引用 | 我要引用此文章
Tags: vbscript
相关日志:
评论: 0 | 引用: 9 | 查看次数: 5902