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

Conditional statement in pdf

New Here ,
Jan 23, 2022 Jan 23, 2022

Copy link to clipboard

Copied

I'm trying to create a pdf form where one field value is calculated by the other but I can't seem to figure out how to make it work. Can you please assist?

 

For example:

A person enters a number in Field 1 that is between 0 and 10

Field 2 populates a number based off of that input.

A person enters a number in Field 1 that is between 11 and 20

Field 2 poputlates a different number based off of that input.

 

 

 

 

 

 

TOPICS
Windows

Views

1.0K

Translate

Translate

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 guidelines
New Here ,
Jan 23, 2022 Jan 23, 2022

Copy link to clipboard

Copied

 

Votes

Translate

Translate

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 guidelines
Community Expert ,
Jan 23, 2022 Jan 23, 2022

Copy link to clipboard

Copied

Read This:

https://www.pdfscripting.com/public/How-to-Write-a-Basic-PDF-Calculation-Script.cfm

and this:

https://acrobatusers.com/tutorials/conditional-execution/

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

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 guidelines
New Here ,
Jan 24, 2022 Jan 24, 2022

Copy link to clipboard

Copied

Thanks! I was able to get it to work; however, I'm having trouble with
conditional statements using drop down list values now .

Below is my syntax

CGBddl is a drop down list... two of the choices are Manager and Director

What I want to happen is when a person selects the rank from the drop down
list, the value of a field = a static value (CVCT) multiplied by the % that
aligns with the rank selection. The only thing that is happening right now
with the script is the CVCT field is being multiplied by

var CGBddl = this.getField("CGBddl").value;
var CVCT = this.getField("CVCT").value;
if( CGBddl = "Manager" ) {event.value = CVCT * 0.04; }
if( CGBddl = "Director" ){event.value = CVCT * .06; }


Can you please assist by providing me some direction on how to get this
script to work properly?

Thanks! David

Votes

Translate

Translate

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 guidelines
Community Expert ,
Jan 24, 2022 Jan 24, 2022

Copy link to clipboard

Copied

In JS the comparison operator is "==" (or "===").

Votes

Translate

Translate

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 guidelines
New Here ,
Jan 31, 2022 Jan 31, 2022

Copy link to clipboard

Copied

Yes, thank you!

 

Votes

Translate

Translate

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 guidelines
New Here ,
Apr 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

LATEST

Hi, i'm trying to do something similar in a timesheet, but what I want is if the total hours add up to more than 40, the excess hours move to the next field. Aka employee 1 worked 43 hours, field 1 (regular hours) totals 40 and field 2 (OT Hrs) totals 3, without the employee having to type it in. Any help would be great, i'm only just learning how to write calculation scripts, so variations are super new.  

Votes

Translate

Translate

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 guidelines