怎么在html网页把阿拉伯数字转换成汉字

大哥们哪位知道,怎么在html网页把阿拉伯数字转换成汉字
最新回答
烟酉

2024-10-23 10:48:36

用js
<script language="javascript">
function transfer()
{
var input=document.forms[0].elements['xiao'].value;
var danwei=Array("","十","百","千","万","十","百","千","亿");
var inputvalue=parseInt(input);
var l=input.length;
var a=new Array(l);
var b=new Array(l);
var result="";
for(var i=0;i<l;i++)
{
a[i]=input.substr(i,1);
b[i]=getchinese(a[i]);
result+=b[i]+danwei[l-i-1];
}
document.forms[0].elements['da'].value=result;
}
function getchinese(p)
{
var input=p;
if(input=="0")
return "零";
else if(input=="1")
return "壹";
else if(input=="2")
return "贰";
else if(input=="3")
return "叁";
else if(input=="4")
return "肆";
else if(input=="5")
return "伍";
else if(input=="6")
return "陆";
else if(input=="7")
return "柒";
else if(input=="8")
return "捌";
else if(input=="9")
return "玖";
}
</script>
<body>
<form>
<input type="text" name="xiao" /><br>
<input type="button" onclick="transfer()" value="数字转换"/><br>
<input type="text" name="da" readonly="true" size="30" style="border-style:dotted; border-color:#9900FF;"/>
</form>
</body>
小糊涂

2024-10-23 11:24:15

哇塞 楼上好猛。。顶一个