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

How do I make a simple calculation with only one of two different fields

Community Beginner ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

Hi! I have a simple calculation that pulls from two different fields. The first field is ALWAYS filled out, and the second field is only filled out once in a while. But if the second field IS filled out, then the info in the first field isn't the correct variable for the calculation, and I need the number from the second field.

For example:

 

Field 1 = 3

Field 2 = "blank"

Calculation Field is:

Field 1 * 1.25 (or 3 * 1.25 = 3.75)

 

But if the user does this:

Field 1 = 3

Field 2 = 4

Then the calculation field is:

Field 2 * 1.25 (or 4 * 1.25 = 5)

 

However, I can't keep one visible and hide the other (I think) because I still need the data in Field 1 to still be seen. Is there a code I can add to the "Custom Calculation Script" section of the "Text Field Properties" box?

TOPICS
Edit and convert PDFs , PDF forms

Views

397

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

correct answers 1 Correct answer

Community Expert , Sep 15, 2020 Sep 15, 2020

You can use this code:

var fld1 = this.getField("Field1").value;
var fld2 = this.getField("Field2").value;
if(fld2 != ""){
event.value = fld2*1.25;}
else event.value = fld1*1.25;

Votes

Translate

Translate
Community Expert ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

You can use this code:

var fld1 = this.getField("Field1").value;
var fld2 = this.getField("Field2").value;
if(fld2 != ""){
event.value = fld2*1.25;}
else event.value = fld1*1.25;

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 Beginner ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

LATEST

Perfecto! Thank you so much NesaNurani. ❤️

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