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

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

Guest
Oct 19, 2020 Oct 19, 2020

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
785
Translate
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
1 ACCEPTED SOLUTION
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

View solution in original post

Translate
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

Use the character ", not “

Use var, not Var

Use if, not If

Info: Acrobat uses Javascript, not Java

Translate
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

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

Translate
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

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 = "";}

Translate
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
LATEST

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

Translate
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