用JavaScript:
<script language="javascript"> function replaceReg(reg, str) { return str.replace(reg, function(m) { return arr[m] }) } arr = new Array("零", "一", "二", "三", "四", "五", "六", "七", "八", "九") var reg = /\d/g var str = '3' document.write(replaceReg(reg, str) + '<br />')</script>用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=0i<li++)
{
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:dottedborder-color:#9900FF"/>
</form>
</body>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)