Skip to main content
rod_skeeter
Participant
October 14, 2016
Answered

Conditional Fields based on a Separate Text Field

  • October 14, 2016
  • 1 reply
  • 571 views

I've searched the forum community and while this question may have been answered previously, I cannot seem to locate quite the same condition.

We have an Order Form that has a Text box ( PROMO_CODE ) where someone can fill in a Specific Word that is supposed to qualify them for a Discount.  I have a separate text box that automatically calculates the Discount regardless of whether the Text is entered called ( Discount_Subtotal ).

( Discount_Subtotal ) is calculating correctly when that specific product is ordered.

What I am trying to do is test for the ( PROMO_CODE ) such that if that specific word is entered, it will pull over the ( Discount_Subtotal ) and be calculated in the Final Total along with Shipping costs if any.

Here is what I have currently for the Javascript:

var nPROMO_CODE = this.getField("PROMO_CODE").value;

if( nPROMO_CODE = "SPECIFIC_WORD") event.value = Discount_Subtotal;

else event.value = 0;

This isn't working however as when I enter the SPECIFIC_WORD, the Discount is not carried over.

Would someone be able to assist with the correct syntax?

Incidentally this is using Adobe Acrobat XI Pro.

Thanks in advance and Kindest Regards,

Don

This topic has been closed for replies.
Correct answer try67

Change this line:

if( nPROMO_CODE = "SPECIFIC_WORD") event.value = Discount_Subtotal;

To:

if (nPROMO_CODE == "SPECIFIC_WORD") event.value = this.getField("Discount_Subtotal").value;

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
October 14, 2016

Change this line:

if( nPROMO_CODE = "SPECIFIC_WORD") event.value = Discount_Subtotal;

To:

if (nPROMO_CODE == "SPECIFIC_WORD") event.value = this.getField("Discount_Subtotal").value;

rod_skeeter
Participant
October 14, 2016

Thank you.

Just tried it and worked just like we wanted it to.

Kindest Regards,

Don