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

How to input different Values based on radio button selection

New Here ,
Jan 09, 2018 Jan 09, 2018

I have a document with 2 different options to choose from. Upfront payment, or monthly repayment.

I need to know what Javascript to write: If option 1 is selected, then value is "Total Cost", but if Option 2 is selected, then value is "Total Cost / 36"

Thanks

TOPICS
Acrobat SDK and JavaScript , Windows
909
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

correct answers 1 Correct answer

Community Expert , Jan 09, 2018 Jan 09, 2018

Make sure the choice values of the radio buttons are set to Choice1 and Choice2.  You'll find the Radio button Choice value on the Options tab of the radio button properties dialog, the

Add this code to the Calculation script for the field that will display the value.

event.value = this.getField("Total Cost").value;

if(this.getField("RadioButton").value == "Choice2")

    event.value = event.value/36;

Translate
Community Expert ,
Jan 09, 2018 Jan 09, 2018

Make sure the choice values of the radio buttons are set to Choice1 and Choice2.  You'll find the Radio button Choice value on the Options tab of the radio button properties dialog, the

Add this code to the Calculation script for the field that will display the value.

event.value = this.getField("Total Cost").value;

if(this.getField("RadioButton").value == "Choice2")

    event.value = event.value/36;

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Jan 10, 2018 Jan 10, 2018

Thank you!

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 21, 2018 May 21, 2018
LATEST

There is no tab for calculation in your example. How do I get to the calculation field to put in the script?

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