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

Populate Text Field when TWO Radio Buttons are De-selected

New Here ,
May 26, 2016 May 26, 2016

Hello,

     I don't know anything about javascript and need some help.  I have a photography contract that I'd like to offer a "bundle discount" of $50 when two services are going to be used.  Service 1 is "Photography Coverage" and Service 2 is "Photo Booth Rental".

Text Field 1 = Subtotal (this calculates the radio button and checkbox values)

Text Field 2 = Discount (This is where I need help.  I'd like this to auto-populate with $50 when my two default radio buttons are un-selected.  But only when BOTH are un-selected)

Text Field 3 = Total (This has a basic calculation of Subtotal-Discount)

The two default services (that I purposely have checked from the start) are both set to values of "0" so the Subtotal stays at $0.  If the customer is only going to use ONE service (meaning one of the default selections will remain selected), then there will be no discount, but if they decide to use both photography and the booth, they save $50.

Can someone please help me write a calculation script for the Discount Text Field, to accomplish what I'm asking?

Untitled-3.jpg

TOPICS
Acrobat SDK and JavaScript
755
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 , May 26, 2016 May 26, 2016

You can use something like this as the custom calculation script of the discount field:

event.value = (this.getField("Service1").value==0 || this.getField("Service2").value==0) ? 0 : 50;

Just adjust the field names in the code to match the actual ones in your file.

Translate
Community Expert ,
May 26, 2016 May 26, 2016

You can use something like this as the custom calculation script of the discount field:

event.value = (this.getField("Service1").value==0 || this.getField("Service2").value==0) ? 0 : 50;

Just adjust the field names in the code to match the actual ones in your file.

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 26, 2016 May 26, 2016

Wow, worked like a charm!  Thanks so much for the quick reply and your knowledge.  Java is not my friend on the coding end, but I do love the capabilities!

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 26, 2016 May 26, 2016

This is actually JavaScript, not Java. Similar names, quite different languages.

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 26, 2016 May 26, 2016

Ah got it, I always thought Java was just short for JavaScript... shows how much I know.  Thanks again!

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 26, 2016 May 26, 2016
LATEST

Don't beat yourself up too much. It's a very common mistake...

On Fri, May 27, 2016 at 12:45 AM, abrownphoto <forums_noreply@adobe.com>

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