<!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=gb2312" />
<title>无标题文档</title>
<script language=javascript>
<!--
function Arabia_to_Chinese(number)
{
var i = 0;
var Mum = number;
for(i=Num.length-1;i>=0;i--)
{
Num = Num.replace(",","")//替换tomoney()中的“,”
Num = Num.replace(" ","")//替换tomoney()中的空格
}
Num = Num.replace("¥","")//替换掉可能出现的¥字符
if(isNaN(Num))
{//验证输入的字符是否为数字
alert("请检查小写金额是否正确");
return;
}
//---字符处理完毕,开始转换,转换采用前后两部分分别转换---//
var part = String(Num).split(".");
var newchar = "";
//小数点前进行转化
for(i=part[0].length-1;i>=0;i--)
{
if(part[0].length > 10)
{
alert("位数过大,无法计算");return "";
}//若数量超过拾亿单位,提示
var tmpnewchar = ""
var perchar = part[0].charAt(i);
switch(perchar)
{
case "0":
tmpnewchar="零" + tmpnewchar;
return document.write(tmpnewchar);
break;
case "1":
tmpnewchar="壹" + tmpnewchar;
return tmpnewchar;
case "2":
tmpnewchar="贰" + tmpnewchar;
return tmpnewchar;
}
}
}
-->
</script>
</head>
<body>
<script language="javascript">
Arabia_to_Chinese(0);
</script>
</body>
</html>
测试什么都没显示,求指教哪里写错了?
------解决方案--------------------
//var Mum = number;
var Num = number.toString();//变量名称错了并且要转为string
------解决方案--------------------
function parseChinese(n) {
var c = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"];
var p = ["分","角","元","拾","百","千","万","拾","百","千","亿","拾","百","千"];
var temp = (/^(0
------解决方案--------------------
[1-9])\d*(\.\d+)?$/).test(n)? n : null;
var i = -1,result = null;
if(temp) {
temp = parseFloat(temp).toFixed(2);
i = (/\.\d+$/).test(temp)? -1 : 1;
result = temp.toString().replace(/\./g, "").split("").reverse().join("").replace(/\d/g, function(a) {i++; return p[i] + c[a]}).split("").reverse().join("").replace(/零(千
------解决方案--------------------
百
------解决方案--------------------