Skip to main content
Participant
May 26, 2016
Answered

Populate Text Field when TWO Radio Buttons are De-selected

  • May 26, 2016
  • 1 reply
  • 846 views

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?

This topic has been closed for replies.
Correct answer try67

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.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
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.

Participant
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!

try67
Community Expert
Community Expert
May 26, 2016

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