0 Replies Latest reply on May 22, 2013 9:17 AM by Neobus78

    Javascript - Formatting Return Values & Removing Decimal in Dollar Amount

    Neobus78

      Hi, I'm looking for some help. I'm new to Javascript and working off my limited knowledge. Below is one item I need help figuring out.

       

      ---JavaScript Registration Fee---

       

      I'm using the following document level Javascript in Acrobat to calculate the pro-rated registration fee based on the current month:

       

      **Note: Text Field "Today" is using the following value:

       

      var f = this.getField("Today");

      if (f.value=="") f.value = util.printd("mm/dd/yyyy", new Date());

       

       

      ---- Below is the Registration Fee Javascript ---

       

      function calculateRegistrationFee() {

       

           var s = this.getField("Today").value;

           if (s!="") {

                var d = util.scand("mm/dd/yyyy", s);

                return (12-(d.getMonth())) * 1.25;

           }

           return "";

      }

       

      I use the following in the Text Field (Text Field Properties ---> Format ---> Custom Format Script) to display the results:

       

      event.value = (calculateRegistrationFee()).toString();

       

       

      1) How can I format the return value to remove the decimal (period) from the results & split into two text fields?

       

      For Question #1 - Example 1, Let's look at this example:

       

      Using the current date (05/22/2013), then

       

      a. The output of the function above = 10

       

      This is a dollar amount so the output 10 is really $10.00. I would enter the cost into two fields (RegFee1 & RegFee2) as "10 00". (See below). So how do I format the return value to enter into these fields correctly?

       

      Registration+Fee+Form+Example+1.jpg

       

      For Question #1 - Example 2, Let's look at this example:

       

      Using the current date (06/22/2013), then

       

      a. The output of the function above = 8.75


      Given the information in the example above, how do I format this return value to enter into these fields correctly?

       

      Thanks,

      Stephen