I have A pdf form With this field
1.Invoice
2.Date
3.Truck No
4.Party Name
5.Party Place
6.City
7.GSTIN
8.Product
9.HSN
10.QTY
11.Rate
12.Amount
13.CGST
14.SGST
15.Total
16.Number
I need to Convert My Number to word By javascript
Example:5279.40=Two Hundred Seventy-Nine and Forty paise
I want to Convert field "Amount" (This is my Numeric Field) To Numbers in "Number" Field
I want Output In Field "NUmber"
I have use a Javscript to Convert this Number
This is My Custum Valiation Script
function ConvertToWords(num)
{
var aUnits = [ "Thousand", "Million", "Billion", "Trillion", "Quadrillion" ];
var cWords = "and ";
// var cWords = (num >= 1 && num < 2) ? "Dollar and " : "Dollars and "; // use for spelled out words
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) ;
cWords += util.printf("%,102/100 Dollars", num); // numerical cents
/* for spelled out cents
if (num > 0) {
cWords += ConvertToHundreds(num) + " Cents"; // spelled out cents
} else {
cWords += "Zero Cents";
}
*/
return cWords;
}
I am using A Custum Calculation Script
Below my Custum Calculation Script JavaScript
var f = this.getField("Total");
event.value = ConvertToHundreds(f.value);
But this script won't give the Output That I need its does not show the Amount After Decimal in Field("Amount")
As you can see in FFigure 1.1
or this code does one more Mistake you Can see In Figure 1.2
Figure 1.2 ("You Can See In "Number" Field Its only Show Forty But my Amount in "Amount" Field is 5040.00 ")
Pls give Me suggestion or a code that is Solve My Problem
Pls dont give me Duplicate of my Question I am Already Search this question on " https://stackoverflow.com" there is no Solution or no Code that Convert Numbers to words In INdian Currency I Found Few of Answer but They Wont work with Indian Currency