JavaScript Access代码参考
///下面是对Access的链接
function getCountfromDB() {
//以当前页面文件为基础,找到文件所在的绝对路径。
var filePath = location.href.substring(0, location.href.indexOf("Cnt.htm"));
var path = filePath + "MyData.mdb";
//去掉字符串中最前面的"files://"这8个字符。
path = path.substring(8);
var updateCnt = 0;
//生成查询和更新用的sql语句。
var sqlSelCnt = "SELECT COUNT from [COUNT] WHERE ID = 'count'";
var sqlUpdCnt = "UPDATE [COUNT] SET [COUNT] = '";
//建立连接,并生成相关字符串
var con = new ActiveXObject("ADODB.Connection");
con.Provider = "Microsoft.Jet.OLEDB.4.0";
con.ConnectionString = "Data Source=" + path;
con.open;
//rs记录表的建立
var rs = new ActiveXObject("ADODB.Recordset");
rs.open(sqlSelCnt, con);
while (!rs.eof) {
var cnt = rs.Fields("COUNT");
document.write(cnt);
//将取得结果加1后更新数据库。
updateCnt = cnt * 1 + 1;
rs.moveNext;
}
rs.close();
rs = null;
sqlUpdCnt = sqlUpdCnt + updateCnt + "'";
con.execute(sqlUpdCnt);
con.close();
con = null;
}
//下面是与文本建立联系
function getCountfromTxt() {
var filePath = location.href.substring(0, location.href.indexOf("Cnt.htm"));
var path = filePath + "count.txt";
path = path.substring(8);
var nextCnt = 0;
&
相关文档:
字母和数字键的键码值(keyCode)
按键
键码
按键
键码
按键
键码
按键
键码
A
65
J
74
S
83
1
49
B
66
K
75
T
84
2
50
C
67
L
76
U
85
3
51
D
68
M
77
V
86
4
52
E
69
N
78
W
87
5
53
F
70
O
79
X
88
6
54
G
71
P
80
Y
89
7
55
H
72
Q
81
Z
90
8
......
javascript里面没有现成的字符串转成日期和时间类型的函数,只能利用new Date(y,m,d,h,i,s,ms)或者其它相似的函数进行转化
以下是一个示例
alert(strToDate('2009/1/5 16:40'));
//字符串转日期类型
function strToDate(str) {
var re=/^(\d{4})\/(\d{1,2})\/(\d{1,2}) (\d{1,2}):(\d{1,2})$/g
if(re.tes ......
//过滤所有的非中文,字母,数字字符
function filter_str(str)
{
interval=typeof(arguments[1])!='undefined'?arguments[1]:' ';
if(str.length>0)str=DBC2SBC(str)
return str.replace(/[^\u4E00-\u9FA5a-zA-Z0-9]/g,in ......
from http://news.csdn.net/a/20100424/218105.html
JavaScript 的成功让人津津乐道,为 Web 网页编写 JavaScript 代码已经是所有 Web 设计师的基本功,这门有趣的语言蕴藏着许多不为人熟知的东西,即使多年的 JavaScript 程序员,也未能完全吃透。本文从7个方面讲述 JavaScript 中那些你不很熟知但非常实用的技巧。
......
JavaScript 有六种数据类型。主要的类型有 number、string、object 以及 Boolean 类型,其他两种类型为 null 和 undefined。
String 字符串类型:字符串是用单引号或双引号来说明的。(使用单引号来输入包含引号的字符串。)如:“The cow jumped over the moon.”
数值数据类型:JavaScript 支持整数和浮点 ......