• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
• Re: Acrobat If, Else, Then statement

# Acrobat If, Else, Then statement

Participant ,
Jul 11, 2022 Jul 11, 2022

Copied

Hi

I am new to PDF scripts and am trying to create one for a form, but getting a little confused with other examples.

Here is what I require.

1. Simple calculation Value 1 + Value 2 = Value 3 (This bit I can do 🙂 )

2. This is the bit I need help on.

Value 3 will sit in Band, named A to I. So I need a script that displays the Band value 3 fits in?

example Value 3 = 10000.

Band A is up to 1000

Band B is between 1000 & 5000

Band C is between 5000 & 15000,

so Value 3, sits in Band C, so I display a C

I hope this is clear?

Mark

TOPICS
JavaScript

Views

155

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Community Expert , Jul 12, 2022 Jul 12, 2022

Hi,

on the validate of the Value 3 you should be able to do something like

``````var bandValue = "";
if ( event.value < 1000){
bandValue = "A";
} else if (( event.value >= 1000) && ( event.value < 5000)){
bandValue = "B";
} else if ((event.value >=5000) && ( event.value < 15000)){
bandValue = "C";
} else {
//catch all in case the value is not any of above
bandValue = "ERROR"
}
// change "BandValue" to the name of your field.
this.getField("BandValue").value = bandValue;``````

Likes

10 Replies 10
Community Expert ,
Jul 12, 2022 Jul 12, 2022

Copied

Hi,

on the validate of the Value 3 you should be able to do something like

``````var bandValue = "";
if ( event.value < 1000){
bandValue = "A";
} else if (( event.value >= 1000) && ( event.value < 5000)){
bandValue = "B";
} else if ((event.value >=5000) && ( event.value < 15000)){
bandValue = "C";
} else {
//catch all in case the value is not any of above
bandValue = "ERROR"
}
// change "BandValue" to the name of your field.
this.getField("BandValue").value = bandValue;``````

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Participant ,
Jul 13, 2022 Jul 13, 2022

Copied

Hi

Thank you for the help. This is great. Unfortunately, I just keep getting an error.

How does the code know it is working with Value 3?

Thanks

Mark

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Jul 13, 2022 Jul 13, 2022

Copied

Because it's associated with it via the event that it triggers.

What does the error you're getting say, exactly?

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Participant ,
Jul 13, 2022 Jul 13, 2022

Copied

I just says error

Do i need to change all BandValues to Value D or just the last one?

Sorry, I really don't know what I am doing.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Jul 13, 2022 Jul 13, 2022

Copied

Ah, the field itself says "ERROR", I see. Where did you place the code, exactly?

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Participant ,
Jul 13, 2022 Jul 13, 2022

Copied

I put it in the custom script box, though it wont work now!

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Jul 13, 2022 Jul 13, 2022

Copied

It's the wrong field and the wrong event. Read the original reply more carefully.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Participant ,
Jul 13, 2022 Jul 13, 2022

Copied

Sorry.  I don't understand.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Jul 13, 2022 Jul 13, 2022

Copied

To quote:

on the validate of the Value 3

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Participant ,
Jul 14, 2022 Jul 14, 2022

Copied

LATEST

I'm sorry. I'm a fool. Thank you for your help. It works now. 🙂

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources