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

Help with Java Script w division when both numbers are 0 until user input

Guest
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

Hello I am a beginning to both Adobe and Java.  

I am trying to do the division of two fields = S5totalotherrev / S5MealequivalentRate

However, both fields are blank until the user enters data, which I discovered returns an error.  So after reading some of the others posts, I wrote the following script: (note I'm only doign the check on S5MealequivalentRate because the data isn't entered until later in the form and I didn't know how to write it to check both)

 

Var nRate = this.getField(“S5MealequivalentRate”).value;

If(nRate !=0){event.value = this.getField(“S5totalotherrev”).value / nRate;} else {event.value = “”;}

 

I'm getting a syntax error and since I basically have no clue when it comes to Java I don't know what I did wrong.  

 

Can someone help me with this script?

 

Thanks

TOPICS
PDF forms

Views

427

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 , Oct 19, 2020 Oct 19, 2020

Use the character ", not “

Use var, not Var

Use if, not If

Info: Acrobat uses Javascript, not Java

Votes

Translate

Translate
Community Expert ,
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

Use the character ", not “

Use var, not Var

Use if, not If

Info: Acrobat uses Javascript, not Java

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
Guest
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

Okay I switched it, but I'm still getting an error.  

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 ,
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

You probably didn't fix all errors.

var nRate = this.getField("S5MealequivalentRate").value;

if(nRate !=0){event.value = this.getField("S5totalotherrev").value / nRate;} else {event.value = "";}

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
Guest
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

LATEST

Thank you.  That worked.  This is so confusing when you don't understand it.

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