【发布时间】:2018-09-03 10:24:48
【问题描述】:
我有一个包含此字段的 pdf 表单
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
我需要通过 javascript 将我的号码转换为单词
示例:5279.40=279 和 40 派萨
我想转换字段“金额”(这是我的数字字段) 到“数字”字段中的数字
我想在字段“NUMber”中输出
我已经使用 Javscript 来转换这个数字
这是我的自定义验证脚本
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;
}
我正在使用自定义计算脚本
在我的自定义计算脚本 JavaScript 下方
var f = this.getField("Total");
event.value = ConvertToHundreds(f.value);
但是这个脚本不会给出我需要的输出 它没有在字段中显示小数点后的金额(“金额”)
如图 1.1 所示
或者这段代码又犯了一个错误,你可以在图 1.2 中看到
Figure 1.2("您可以在“数字”字段中看到它只显示 40 但我在“金额”字段中的金额是 5040.00")
请给我建议或解决我的问题的代码
请不要给我我的问题的重复我已经在“上搜索这个问题” https://stackoverflow.com" 没有解决方案或没有将数字转换为印度货币单词的代码我发现很少有答案,但它们不适用于印度货币
【问题讨论】:
-
你能把 ConvertToHundreds() 也加进去吗?
-
是的,我添加了 ConvertToHundreds 及其工作,但它的输出不是我想要的
标签: javascript pdf adobe acrobat adobe-javascript