<html>
<script type="text/javascript">
function change(){
var text=document.getElementById("textbox").value //获得文本值
var code = text.charCodeAt(0)//转换成ASCII码
var num
if(code<=90 &&code >=65){
num = code - 65+1
}else if(code<=122 &&code >=97){
num = code - 97+1
}
document.getElementById("textbox").value = num
}
</script>
<body>
<input type = "textbox" id = "textbox" >
<input type = "button" value = "替换" onclick = "change()"></>
</body>
</html>
用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条)