• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Number to word in indian format

Engaged ,
Dec 25, 2018 Dec 25, 2018

Copy link to clipboard

Copied

I have the following script :

aTens = [ "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];

aOnes = [ "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",

"Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen",

"Nineteen" ];

function ConvertToHundreds(num)

{

var cNum, nNum;

var cWords = "";

num %= 1000;

if (num > 99) {

/* Hundreds. */

cNum = String(num);

nNum = Number(cNum.charAt(0));

cWords += aOnes[nNum] + " Hundred";

num %= 100;

if (num > 0)

cWords += " and "

}

if (num > 19) {

/* Tens. */

cNum = String(num);

nNum = Number(cNum.charAt(0));

cWords += aTens[nNum - 2];

num %= 10;

if (num > 0)

cWords += "-";

}

if (num > 0) {

/* Ones and teens. */

nNum = Math.floor(num);

cWords += aOnes[nNum];

}

return cWords;

}

function ConvertToWords(num)

{

var aUnits = [ "Thousand", "Million", "Billion", "Trillion", "Quadrillion" ];

var cWords = (num >= 1 && num < 2) ? "Dollar and " : "Dollars and ";

var nLeft = Math.floor(num);

for (var i = 0; nLeft > 0; i++) {

if (nLeft % 1000 > 0) {

if (i != 0)

cWords = ConvertToHundreds(nLeft) + " " + aUnits[i - 1] + " " + cWords;

else

cWords = ConvertToHundreds(nLeft) + " " + cWords;

}

nLeft = Math.floor(nLeft / 1000);

}

num = Math.round(num * 100) % 100;

if (num > 0)

cWords += ConvertToHundreds(num) + " Cents";

else

cWords += "Zero Cents";

return cWords;

}

This script works perfectly for US number system........but i want this in Indian Number system

like :  50,000 is Fifty Thousand

          5,00,000  is Five Lakhs

         50,00,000 is Fifty Lakhs

         5,00,00,000 is Five crores     i.e     instead of         [ "Thousand", "Million", "Billion", "Trillion", "Quadrillion" ]

                                                                      i want         ["Thousand", "Lakhs", "Crores"]

Thanks.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

227

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 25, 2018 Dec 25, 2018

Yes it would be possible for you to make these changes if you learn JavaScrops and carefully study how it works. It’s a slightly awkward change.

Likes

Translate

Translate
LEGEND ,
Dec 25, 2018 Dec 25, 2018

Copy link to clipboard

Copied

Yes it would be possible for you to make these changes if you learn JavaScrops and carefully study how it works. It’s a slightly awkward change.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 26, 2022 Sep 26, 2022

Copy link to clipboard

Copied

LATEST

function number2text(value) {
var fraction = Math.round(frac(value)*100);
var f_text = "";

if(fraction > 0) {
f_text = "AND "+convert_number(fraction)+" PAISE";
}

return convert_number(value)+" RUPEE "+f_text+" ONLY";
}

function frac(f) {
return f % 1;
}

function convert_number(number)
{
if ((number < 0) || (number > 999999999))
{
return "NUMBER OUT OF RANGE!";
}
var Gn = Math.floor(number / 10000000); /* Crore */
number -= Gn * 10000000;
var kn = Math.floor(number / 100000); /* lakhs */
number -= kn * 100000;
var Hn = Math.floor(number / 1000); /* thousand */
number -= Hn * 1000;
var Dn = Math.floor(number / 100); /* Tens (deca) */
number = number % 100; /* Ones */
var tn= Math.floor(number / 10);
var one=Math.floor(number % 10);
var res = "";

if (Gn>0)
{
res += (convert_number(Gn) + " CRORE");
}
if (kn>0)
{
res += (((res=="") ? "" : " ") +
convert_number(kn) + " LAKH");
}
if (Hn>0)
{
res += (((res=="") ? "" : " ") +
convert_number(Hn) + " THOUSAND");
}

if (Dn)
{
res += (((res=="") ? "" : " ") +
convert_number(Dn) + " HUNDRED");
}


var ones = Array("", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX","SEVEN", "EIGHT", "NINE", "TEN", "ELEVEN", "TWELVE", "THIRTEEN","FOURTEEN", "FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN","NINETEEN");
var tens = Array("", "", "TWENTY", "THIRTY", "FOURTY", "FIFTY", "SIXTY","SEVENTY", "EIGHTY", "NINETY");

if (tn>0 || one>0)
{
if (!(res==""))
{
res += " AND ";
}
if (tn < 2)
{
res += ones[tn * 10 + one];
}
else
{

res += tens[tn];
if (one>0)
{
res += ("-" + ones[one]);
}
}
}

if (res=="")
{
res = "zero";
}
return res;
}

var a = frmTotalAmounts.frmTotalAmount.frmHiddenAmount.decAmount.rawValue;

var number = number2text(a);
this.rawValue = number;

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines