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

Converting numbers to words - common scripting not working

Explorer ,
Mar 04, 2017 Mar 04, 2017

Looking to see if anyone here knows the answer (because I'm at the end of my rope/ability)...

Trying to get the Number under "Payoff" to then convert into words under the "WORDS" section. Using the common calculation scripting that available everywhere, but it's not working. This is a multi page document, with about a dozen different inputs, but not sure why that would affect anything.

Anything obvious I'm missing here or any workarounds? Thanks!

words.jpg

TOPICS
PDF forms
1.6K
Translate
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
1 ACCEPTED SOLUTION
LEGEND ,
Mar 04, 2017 Mar 04, 2017

Dud you add the document level script " ConverttoWords"?

View solution in original post

Translate
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
LEGEND ,
Mar 04, 2017 Mar 04, 2017

Dud you add the document level script " ConverttoWords"?

Translate
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
Explorer ,
Mar 05, 2017 Mar 05, 2017

Here's where my ignorance comes in...no, I didn't. That's it! Thanks.

Translate
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
LEGEND ,
Mar 06, 2017 Mar 06, 2017
LATEST

Here's the code for check amounts:

function ConvertToHundreds(num)

{

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" ];

   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;

   cWords += util.printf("%,102.0f", num) + "/100"

   return cWords;

}

Translate
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