写一个类似下面的方法,然后取各个值,再调用下面的方法switch(x)
      {
         case 0 : 
            strNum="零";
            break;
         case 1 :
            strNum="一";
            break;
         case 2 :
            strNum="二";
            break;
         case 3 : 
            strNum="三";
            break;
         case 4 : 
            strNum="四";
            break;
         case 5 :
            strNum="五";
            break;
         case 6 : 
            strNum="六";
            break;
         case 7 : 
            strNum="七";
            break;
         case 8 :
            strNum="八";
            break;
         default:
            strNum="九";
            break;
      }

解决方案 »

  1.   

    <script>
    function toChinese(num) 
    {
        if(!/^\d*$/.test(num)){alert("Number is wrong!"); return "Number is wrong!";}    var AA = new Array("零","一","二","三","四","五","六","七","八","九");
        var str = ""+num;
        var rst = "";
        for(var i=0; i<str.length; i++)
        {
            rst += AA[parseInt(str.charAt(i))];
        }
        return rst;
    }
    alert(Chinese(2005))
    </script>
      

  2.   

    <script>
    function toChinese(num) 
    {
        if(!/^\d*$/.test(num)){alert("Number is wrong!"); return "Number is wrong!";}    var AA = new Array("零","一","二","三","四","五","六","七","八","九");
        var str = ""+num;
        var rst = "";
        for(var i=0; i<str.length; i++)
        {
            rst += AA[parseInt(str.charAt(i))];
        }
        return rst;
    }
    alert(toChinese(2005))
    </script>
      

  3.   

    function toChinese(num) 
    {
    if(!/^\d*$/.test(num)){alert("Number is wrong!"); return "Number is wrong!";}
    var s='',a='零一二三四五六七八九';
    num=''+num;
    for(var i=0;i<num.length;i++)s+=a.charAt(num.charCodeAt(i)-48);
    return s;
    }
      

  4.   

    function ChangeDate(dates,type){ //dates - 或年,或月,或日 , type - 3 是 年,2 是 月,1 是 日
    var arrNum = new Array(11)
    var arrText = new Array(14)
    var strYear,strMonth,strDay,i
    var temp
    dates = new String(dates);
    temp = ""
    arrNum[0]="O"
    arrNum[1]="1"
    arrNum[2]="2"
    arrNum[3]="3"
    arrNum[4]="4"
    arrNum[5]="5"
    arrNum[6]="6"
    arrNum[7]="7"
    arrNum[8]="8"
    arrNum[9]="9"
    arrNum[10]="10"
    arrText[0]="O"
    arrText[1]="一"
    arrText[2]="二"
    arrText[3]="三"
    arrText[4]="四"
    arrText[5]="五"
    arrText[6]="六"
    arrText[7]="七"
    arrText[8]="八"
    arrText[9]="九"
    arrText[10]=""
    arrText[11]="十"
    arrText[12]="二十"
    arrText[13]="三十"
    if (type == '3'){
    for (i=1; i <= dates.length ;i++){
    temp+=arrText[parseInt(dates.charAt(i-1))]
    }
    }
    if (type == '2'){
    if (dates.length == 2) {
    if (dates=="10") {
    temp = "十"
    }else{
    temp = "十" + arrText[parseInt( dates.substr(1,1) )]
    }
    }else{
    temp = arrText[parseInt(dates)]
    }
    }
    if (type == '1'){
    if (dates.length == 2) {
    if (dates=="10") {
    temp = "十"
    }else if (dates=="20") {
    temp = "二十"
    }else if (dates=="30") {
    temp = "三十"
    }else{
    temp = arrText['1'+parseInt( dates.substr(0,1) )] + arrText[parseInt( dates.substr(1,1) )]
    }
    }else{
    temp = arrText[parseInt(dates)]
    }
    }
    return temp;
    }