Highlighted

Confused about If Then Statements

Community Beginner ,
Oct 15, 2020

Copy link to clipboard

Copied

I'm converting a Projected Operating Costs spreadsheet from Excel to Adobe since some of my end users do not have Excel and Google takes away the security features in the document.

 

I have no experiencing with Java and am really struggling grasping how to write an if then statement for one of the fields.

 

The Text field needs to look at another field "S2HRFreeCount" and determine if it is greater than '0'.  If it is greater than '0' I want it to display the value I have entered in another field "S2HRFreeRate."  This rate changes every year so I'm wanting to use it from the field rather then enter the value in the script.  Less places to update.  If  there is no text in "S2HRFreeCount" than I want the field to either be blank or display "0."

 

My end user does not need to enter a value in field S2HRFreeCount. 

 

Any assistance would be appreciated.  I've only started creating Adobe Fillable Forms within the last 6 months so I'm learning as I go.  And this is the most complicated component so far.

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

The easiest way to do this is a Custom Calculation script on the text field. 

 

 

var cFreeCount = this.getField("S2HRFreeCount").valueAsString;
if((cFreeCount != "") && !isNaN(cFreeCount) && (Number(cFreeCount) > 0))
  event.value = this.getField("S2HRFreeRate").value;
else
  event.value = "";

 

 

Note that there are 3 conditions used to determine whether or not the FreeRate value is used. 

The FreeCount field is not empty, it's value is a number, and that number is greater than 0;

 

You can read more about calculation scripts here:

https://www.pdfscripting.com/public/Calculating-field-values-and-more.cfm

And about if statements in calculations here:

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

 

TOPICS
Edit and convert PDFs, PDF forms

Views

51

Likes

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

Confused about If Then Statements

Community Beginner ,
Oct 15, 2020

Copy link to clipboard

Copied

I'm converting a Projected Operating Costs spreadsheet from Excel to Adobe since some of my end users do not have Excel and Google takes away the security features in the document.

 

I have no experiencing with Java and am really struggling grasping how to write an if then statement for one of the fields.

 

The Text field needs to look at another field "S2HRFreeCount" and determine if it is greater than '0'.  If it is greater than '0' I want it to display the value I have entered in another field "S2HRFreeRate."  This rate changes every year so I'm wanting to use it from the field rather then enter the value in the script.  Less places to update.  If  there is no text in "S2HRFreeCount" than I want the field to either be blank or display "0."

 

My end user does not need to enter a value in field S2HRFreeCount. 

 

Any assistance would be appreciated.  I've only started creating Adobe Fillable Forms within the last 6 months so I'm learning as I go.  And this is the most complicated component so far.

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

The easiest way to do this is a Custom Calculation script on the text field. 

 

 

var cFreeCount = this.getField("S2HRFreeCount").valueAsString;
if((cFreeCount != "") && !isNaN(cFreeCount) && (Number(cFreeCount) > 0))
  event.value = this.getField("S2HRFreeRate").value;
else
  event.value = "";

 

 

Note that there are 3 conditions used to determine whether or not the FreeRate value is used. 

The FreeCount field is not empty, it's value is a number, and that number is greater than 0;

 

You can read more about calculation scripts here:

https://www.pdfscripting.com/public/Calculating-field-values-and-more.cfm

And about if statements in calculations here:

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

 

TOPICS
Edit and convert PDFs, PDF forms

Views

52

Likes

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
Oct 15, 2020 0
Adobe Community Professional ,
Oct 15, 2020

Copy link to clipboard

Copied

The easiest way to do this is a Custom Calculation script on the text field. 

 

 

var cFreeCount = this.getField("S2HRFreeCount").valueAsString;
if((cFreeCount != "") && !isNaN(cFreeCount) && (Number(cFreeCount) > 0))
  event.value = this.getField("S2HRFreeRate").value;
else
  event.value = "";

 

 

Note that there are 3 conditions used to determine whether or not the FreeRate value is used. 

The FreeCount field is not empty, it's value is a number, and that number is greater than 0;

 

You can read more about calculation scripts here:

https://www.pdfscripting.com/public/Calculating-field-values-and-more.cfm

And about if statements in calculations here:

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

 

Likes

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
Reply
Loading...
Oct 15, 2020 2
Community Beginner ,
Oct 16, 2020

Copy link to clipboard

Copied

Thank you.  I have so much more to learn about these advance features in Adobe.  But making the conversion to Adobe will make my life so much easier in the long run.

Likes

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
Reply
Loading...
Oct 16, 2020 0