functiontransform (tranvalue) {Try { vari = 1; varDW2 =NewArray ("", "Million", "billion");//Large Units varDW1 =NewArray ("Pick", "Bai", "thousand");//Small Units varDW =NewArray ("0", "one", "II", "three", "Restaurant", "WU", "Lu", "Qi", "ba", "JIU");//integer part with //The following is lowercase converted to uppercase in the total uppercase text box //separating integers from decimals varSource =splits (Tranvalue); varnum = source[0]; varDig = source[1]; //Convert integer part varK1 = 0;//count Small units varK2 = 0;//count Large units varsum = 0; varstr = ""; varlen = source[0].length;//the length of an integer for(i = 1; I <= Len; i++) { varn = Source[0].charat (len-i);//get a number on a single digit varbn = 0; if(len-i-1 >= 0) {bn= Source[0].charat (Len-i-1);//get a number on a single digit before the first one} sum= Sum +Number (n); if(Sum! = 0) {str= Dw[number (n)].concat (str);//get the uppercase number corresponding to the number and insert it in front of the STR string if(n = = ' 0 ') sum = 0; } if(len-i-1 >= 0) {//within the range of numbers if(K1! = 3) {//Add small units if(Bn! = 0) {str=Dw1[k1].concat (str); } K1++; } Else{//do not add small units, increase unitsK1 = 0; vartemp = Str.charat (0); if(temp = = "Million" | | temp = = "million")//If there is no number in front of the large unitstr = STR.SUBSTR (1, str.length-1); STR=Dw2[k2].concat (str); Sum= 0; } } if(K1 = = 3)//small units to thousands of large units into a{K2++; } } //Converting a decimal part varStrdig = ""; if(Dig! = "") { varn = Dig.charat (0); if(n! = 0) {Strdig+ = Dw[number (n)] + "angle";//Plus numbers } varn = Dig.charat (1); if(n! = 0) {Strdig+ = Dw[number (n)] + "min";//Plus numbers}} str+ = "Yuan" +Strdig; } Catch(e) {return"0 Yuan"; } returnstr;}//splitting integers and decimalsfunctionSplits (tranvalue) {varValue =NewArray (' ', ' '); Temp= Tranvalue.split ("."); for(vari = 0; i < temp.length; i++) {Value[i]=Temp[i]; } returnvalue;}
Native JavaScript implements amount capitalization conversion function