JS to achieve the amount of conversion (to enter the Arabia digital) into Chines

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

When a project is encountered, then hold down, collected, I hope useful for everyone

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>Untitled Document</title>

<script type="text/javascript" language="javascript">

function clickchange(obj){

var aaval=obj.value;

alert(aaval);

document.getElementById("bb").value=ChinaCost(aaval);

}

function ChinaCost(numberValue){

var numberValue=new String(Math.round(numberValue*100)); // Amount in figures

var chineseValue=""; // The amount of Chinese characters conversion

var String1 = "Lingyiersansiwuluqibajiu "; // Chinese characters

var String2 = "Bai billion million thousand thousand hundred ten thousand thousand hundred ten yuan corner points "; // the corresponding unit

var len=numberValue.length; // The string length of numberValue

var Ch1; // Digital Chinese pronunciation

var Ch2; // Figure of Chinese characters pronunciation

var nZero=0; // Used to calculate the number of consecutive zeros

var String3; // The value of the specified location

if(len>15){

alert("Beyond the calculation range");

return "";

}

if (numberValue==0){

chineseValue = "Zero yuan";

return chineseValue;

}

String2 = String2.substr(String2.length-len, len); // Take out the corresponding digit STRING2 value

for(var i=0; i<len; i++){

String3 = parseInt(numberValue.substr(i, 1),10); // The value of one out of the need to convert the

if ( i != (len - 3) && i != (len - 7) && i != (len - 11) && i !=(len - 15) ){

if ( String3 == 0 ){

Ch1 = "";

Ch2 = "";

nZero = nZero + 1;

}

else if ( String3 != 0 && nZero != 0 ){

Ch1 = "Fatal Frame" + String1.substr(String3, 1);

Ch2 = String2.substr(i, 1);

nZero = 0;

}

else{

Ch1 = String1.substr(String3, 1);

Ch2 = String2.substr(i, 1);

nZero = 0;

}

}

else{ // This is a trillion, trillion yuan, million, a key position

if( String3 != 0 && nZero != 0 ){

Ch1 = "Fatal Frame" + String1.substr(String3, 1);

Ch2 = String2.substr(i, 1);

nZero = 0;

}

else if ( String3 != 0 && nZero == 0 ){

Ch1 = String1.substr(String3, 1);

Ch2 = String2.substr(i, 1);

nZero = 0;

}

else if( String3 == 0 && nZero >= 3 ){

Ch1 = "";

Ch2 = "";

nZero = nZero + 1;

}

else{

Ch1 = "";

Ch2 = String2.substr(i, 1);

nZero = nZero + 1;

}

if( i == (len - 11) || i == (len - 3)){ // If this bit is a billion bits or element, you must write

Ch2 = String2.substr(i, 1);

}

}

chineseValue = chineseValue + Ch1 + Ch2;

}

if ( String3 == 0 ){ // The last one (points) is 0, and the “”

chineseValue = chineseValue + "The whole";

}

return chineseValue;

}

</script>

</head>

<body>

<input type="text" id="aa" onblur="clickchange(this)" />

<input type="text" id="bb" />

</body>

</html>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Moses at November 17, 2013 - 5:43 PM