常用Javascript操作收集
• 小写金额与大写金额联动
<mce:script language="JavaScript"><!--
function daxie()
{
this.values = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"];
this.digits = ["", "拾", "佰", "仟"];
}
function daxie.prototype.getdx(num)
{
if(isNaN(num)) return "";
var number = Math.round(num*100)/100;
number = number.toString(10).split('.');
var integer = number[0];
var len = integer.length;
if (len > 12)
return "数值超出范围!支持的最大数值为 999999999999.99";
var returnValue = this.bns(integer.slice(-4));
if (len > 4)
returnValue = this.bns(integer.slice(-8,-4)) + (integer.slice(-8,-4)!="0000"?"万":"") + returnValue;
if (len > 8)
returnValue = this.bns(integer.slice(-12,-8)) + "亿" + returnValue;
if(returnValue!="")
returnValue += "圆";
if(number.length==2)
{
var cok = number[1].split('');
if(returnValue!="" || cok[0]!="0")
returnValue += this.values[parseInt(cok[0])] + (cok[0]!="0"?"角":"");
if(cok.length>=2)
returnValue += this.values[parseInt(cok[1])] + "分";
}
if(returnValue!="" && !/分$/.test(returnValue))
returnValue += "整";
return returnValue;
}
function daxie.prototype.bns(str)
{
var num = str.split('');
var dsl = num.length-1;
var returnValue = "";
for (var i=0; i<=dsl; i++)
returnValue += this.values[parseInt(num[i])] + (num[i]!='0'?this.digits[dsl-i]:"");
returnValue = returnValue.replace(/零+$/, "").replace(/零{2,}/, "零");
return returnValue;
}
//////////////////////////////////////////////
var stmp = "";
var dfs = new daxie();
function nst(t)
{
if(t.value==stmp) return;
var ms = t.value.replace(/[^\d\.]/g,"").replace(/(\.\d{2}).+$/,"$1");
var txt = ms.split(".");
while(/\d{4}(,|$)/.test(txt[0]))
txt[0] = txt[0].replace(/(\d)(\d{3}(,|$))/,"$1,$2");
t.value = stmp = txt[0]+(txt.length>1?"."+txt[1]:"");
bbb.innerHTML ="<font color=red>"+dfs.getdx(parseFloat(ms))+"</font>";
}
// --></mce:script>
小写金额:<input type="text" name="aaa"
相关文档:
以下以 IE 代替 Internet Explorer,以 MF 代替 Mozzila Firefox
1. document.form.item 问题
(1)现有问题:
现有代码中存在许多 document.formName.item("itemName") 这样的语句,不能在 MF 下运行
(2)解决方法:
&nb ......
下面都是个人理解以及查找的网上的资料,如有不对的地方请指正
This
this 始终指向调用它的对象 ,都没有对象调用时就指向window
另外就是this一般都是在function中,当不在function中的时候 一定是指向window的.
var a ='a';
alert(this.a); //出来的是a
alert(this.b); //undefined 因为还没定义 ......
调用JavaScript文件
用作导航栏
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ......
引言
我们已经探讨过了必要的程序设计核心概念。现在是时候从细节中退出来,并高瞻远瞩地来看看你可以利用 JavaScript 来做些什么了——为什么你要花时间来学习这样一门复杂的功课,以及如何将其用到你的网页上?
过去的几年对我来说是一段有趣的时间,因为在这段时间里 JavaScript 的使用从一种边缘知识成为了 ......