Archive for the 'Web Development' Category

HTML <Button> 标签的默认 Type 属性

Posted on 2008-02-21 in Web DevelopmentComments

在装上 K2 RC4 主题后,发现如果用 IE 访问 WP 后台无法保存 K2 的设置选项,点击 Save 按钮后毫无反应,Firefox、Opera、Safari则正常。看了看源代码,K2 是这样定义这个按钮的:

<button><?php echo attribute_escape(__('Save','k2_domain'));?></button>

之前很少使用过 <button> 标签,所以开始还以为 K2 绑定了按钮事件不支持 IE,不过浏览了一通代码也没找到,才意识到问题可能出在标签的未指定 type 属性上了,于是加上 type="submit",问题解决。

又特意找了找相关资料,W3C 对 button 标签的 type 属性定义是:

submit: Creates a submit button. This is the default value.
 reset: Creates a reset button.
button: Creates a push button.

MSDN 中则如此解释:

button: Default. Creates a Command button.
 reset: Creates a Reset button. If the button is in a form,
        it resets the fields in the form to their initial values.
submit: Creates a Submit button. If the button is in a form,
        it submits the form.

原来如此。fuck IE!

JScript 仿 PHP 操作 SQL Server

Posted on 2006-01-13 in Web DevelopmentComments

原先在php下写了个操作数据库的类,用jscript又重写了一遍。

// Sample
var db = new dbstuff();
db.connect(dbserver, dbuser, dbpwd, dbname);
 
var sql = "SELECT @@VERSION as dbv";
var query = db.query(sql);
while(arr = db.fetch_array(query)){
  echo(arr["dbv"]);
}
db.close();

Continue reading...

PHP 操作 SQL Server

Posted on 2005-11-20 in Web DevelopmentComments

adodb 实在太庞大了,况且也不需要那么多的功能,就自己写了一个 PHP 操作 SQL Server 的类。带有强烈的 discuz 风格。

// sample
$db = new dbstuff;
$db->connect($dbserver, $dbuser, $dbpwd, $dbname, $codepage);

Continue reading...

自动记录操作日志

Posted on 2004-12-29 in Web DevelopmentComments

通常对数据的操作都需要记录日志,由于表结构的不同,每次都需要重新组织 SQL 语句则显得相当繁琐。写了几个函数来解决这个问题,不过有局限性:表的第一个字段必须为 id int identity。

// Sample
// 生成日志表
createlogtable($table);
// 生成记录操作日志的SQL语句
$logsql = genopelogsql($table, "id=$id", 'update');
// 将日志记录SQL拼接到原SQL
$sql = $logsql.$sql;
// 执行操作
$db->query($sql);

Continue reading...