Skip to main content
New Participant
July 17, 2019
Answered

If, then validation scripts

  • July 17, 2019
  • 2 replies
  • 4717 views

Hi Guys, I'm a novice just starting with validation and calculation scripts.

I have a PDF form that has 5 calculated $ fields using calculation scripts. (we'll call them field, field2, field3, field4, field5)

I have a dropdown field that if the value selected is 1, the "amount due" field should return the value of field1

if value entered is 2, "amount due" field should return the value of field2

if value entered is 3, "amount due" field should return the value of field3

if value entered is 4, "amount due" field should return the value of field4

and if value entered is 5, "amount due" field should return the value of field5

I have tried everything I could find from reading several forums but I keep getting errors.

Can someone PLEASE help?

Thank you in advance 

This topic has been closed for replies.
Correct answer try67

Let's say it's called "Dropdown1". You can use this code as the custom calculation script of "Amount Due":

var v = this.getField("Dropdown1").valueAsString;

if (v=="1") event.value = this.getField("field1").valueAsString;

else if (v=="2") event.value = this.getField("field2").valueAsString;

else if (v=="3") event.value = this.getField("field3").valueAsString;

else if (v=="4") event.value = this.getField("field4").valueAsString;

else if (v=="5") event.value = this.getField("field5").valueAsString;

else event.value = "";

2 replies

joeapomAuthor
New Participant
July 17, 2019

Invoice #

try67
Community Expert
July 17, 2019

Then insert that into the quotes in the first line of the code I posted above.

try67
Community Expert
July 17, 2019

What's the name of the dropdown field?

try67
try67Correct answer
Community Expert
July 17, 2019

Let's say it's called "Dropdown1". You can use this code as the custom calculation script of "Amount Due":

var v = this.getField("Dropdown1").valueAsString;

if (v=="1") event.value = this.getField("field1").valueAsString;

else if (v=="2") event.value = this.getField("field2").valueAsString;

else if (v=="3") event.value = this.getField("field3").valueAsString;

else if (v=="4") event.value = this.getField("field4").valueAsString;

else if (v=="5") event.value = this.getField("field5").valueAsString;

else event.value = "";

joeapomAuthor
New Participant
July 17, 2019

try67

AMAZING!!! All I can say. I have spent over 4 hours reading and trying out different validation scripts on the dropdown field (Not the Amount Due) as some forums recommended and nothing worked.

I cant thank you enough!!

Joe