Skip navigation
govrellic
Currently Being Moderated

How to change currency symbol and calculation depending on checkbox?

Jul 31, 2012 4:02 PM

Tags: #javascript #forms #acrobat_9_pro #formatting_fields

I am constructing a packing slip form with simple calculations, Quantity  x  Unit = SubTotal, but i need the calculation and the currency symbol to change depending on which radio box is chosen, USD or Yen (USD has decimal point where as the Yen does not).

 

Is there a simple javascript?

 

I use Acrobat9 pro

 
Replies
  • George Johnson
    11,659 posts
    Aug 11, 2002
    Currently Being Moderated
    Jul 31, 2012 5:14 PM   in reply to govrellic

    Sure. You have to create a document-level JavaScript and add to it a function like the following:

     

    function dollar_yenFormat() {

     

        // Get the value of the radio button

        var curr = getField("currency").value;

     

        // Determine the number of decimal places

        var nd = curr === "Yen" ? 0 : 2;

     

        // Determine the currency symbol

        var cs = curr === "Yen" ? "\u00a5" : "\u0024";

     

        // Set the format options

        AFNumber_Format(nd, 0, 0, 0, cs, true);

     

    }

     

    Replace "currency" with the actual name of the radio button group, and set the export value (Radio Button Choice) to "Yen" for the Yen radio button.

     

    Now you can set the custom Format script for the SubTotal field to the following:

     

    // Custom Format script for SubTotal field

    dollar_yenFormat();

     

    You can do the same for the grand total field or any other that need this.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points