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

Override Calculation Based on Radio Button Value

New Here ,
May 18, 2017 May 18, 2017

Hello,

I'm using Adobe Pro DC and I have created a form that uses both text boxes and radio buttons. The text boxes and radio buttons that I'm focusing on are involved in calculations. I'm attempting to calculate a field based on a radio button selection.

Here are the involved text boxes: Commitment amount, Payment amount, # of payments, Total pledge

Here is the involved radio button group (Pledge payment frequency): Annual, Quarterly, Semi-annual, Monthly, Other

A text version of the calculation is as follows:

  • Commitment amount = Total pledge
  • Payment amount = Total pledge / # of Payments
  • # of payments = calculated based on the selected radio button (e.g., selecting Annual means # of Payments = 1, selecting Quarterly means # of Payments = 4, etc.)

The calculation works perfect for all of the radio button options except for "Other". Here, I'd like for the user to be able to enter a value into # of Payments manually and have the Payment amount calculated based on the manual entry. Currently, it allows me to enter a value, but when I exit the # of Payments field, the value disappears.

Is there a way to allow both automatic and manual calculations in one field?

Custom calculation script for # of payments field

var frequency = this.getField("Pledge payment frequency").value;

var payment = this.getField("Number of Payments");

if (frequency == "Off") {

    event.value = "";

}

else if (frequency == "Annual") {

    event.value = "1";

payment.required=false;

}

else if (frequency == "Quarterly") {

    event.value = "4";

payment.required=false;

}

else if (frequency == "Semiannual") {

    event.value = "2";

payment.required=false;

}

else if (frequency == "Monthly") {

    event.value = "12";

payment.required=false;

}

else if (frequency == "Other") {

    event.value = "";

payment.required=true;

}

else {

    event.value == ""; // we don't know about this frequency type!

}

Thanks in advance!

TOPICS
PDF forms
3.1K
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
Community Expert ,
May 19, 2017 May 19, 2017

Yes :

if (frequency == "Off") {

    event.value = "";

}

else if (frequency == "Annual") {

    event.value = 1;

payment.required=false;

}

else if (frequency == "Quarterly") {

    event.value = 4;

payment.required=false;

}

else if (frequency == "Semiannual") {

    event.value = 2;

payment.required=false;

}

else if (frequency == "Monthly") {

    event.value = 12;

payment.required=false;

}

// also test if the text field is not empty

else if (frequency == "Other" && this.getField("OTHER-TEXT").valueAsString.length > 0) { 

 

    event.value = this.getField("OTHER-TEXT").value; 

 

payment.required=true; 

 

}

else {

    event.value = ""; // we don't know about this frequency type!

}

//

.


Acrobate du PDF, InDesigner et Photoshopographe

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
Community Expert ,
May 19, 2017 May 19, 2017

Yes :

if (frequency == "Off") {

    event.value = "";

}

else if (frequency == "Annual") {

    event.value = 1;

payment.required=false;

}

else if (frequency == "Quarterly") {

    event.value = 4;

payment.required=false;

}

else if (frequency == "Semiannual") {

    event.value = 2;

payment.required=false;

}

else if (frequency == "Monthly") {

    event.value = 12;

payment.required=false;

}

// also test if the text field is not empty

else if (frequency == "Other" && this.getField("OTHER-TEXT").valueAsString.length > 0) { 

 

    event.value = this.getField("OTHER-TEXT").value; 

 

payment.required=true; 

 

}

else {

    event.value = ""; // we don't know about this frequency type!

}

//

.


Acrobate du PDF, InDesigner et Photoshopographe
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
New Here ,
May 19, 2017 May 19, 2017
LATEST

Thanks, JR!!!

I spent hours last night searching for answer on my own before posting to the forum.

I had to update the name of the field you added to the last else if, but otherwise it works perfectly!

I appreciate the quick and correct response!

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