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

Script with multiple fields calculated and leave blank no data

Community Beginner ,
Nov 07, 2018 Nov 07, 2018

Looking for some assistance for a script that runs the calculations below based on the fields but also leaves the final field blank if nothing is in the other fields.   

E12*E13*(E14/100)/2000

For example:

25*12.2*(27.5/100)/2000=0.0419

Any assistance is greatly appreciated.

DH

TOPICS
Acrobat SDK and JavaScript , Windows
947
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

correct answers 1 Correct answer

Community Beginner , Nov 16, 2018 Nov 16, 2018

It's fixed! Thanks for catching that, don't know how I missed it. Much appreciated!

Translate
Community Expert ,
Nov 07, 2018 Nov 07, 2018

Use this code as the custom calculation script of the field where you want to show the result:

var v1 = this.getField("E12").valueAsString;

var v2 = this.getField("E13").valueAsString;

var v3 = this.getField("E14").valueAsString;

if (v1=="" || v2=="" || v3=="") event.value = "";

else event.value = Number(v1)*Number(v2)*((Number(v3)/100)/2000);

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 Beginner ,
Nov 07, 2018 Nov 07, 2018

Thank you for your quick response!  What would be the script for this one? 

B10*C10*(D10/100)*(E10/100)/2000

76*9.42*(14.5/100)*(33/100)/2000=0.0171

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 ,
Nov 07, 2018 Nov 07, 2018

Just follow the same logic I provided above...

You should also read this tutorial: https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations

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 Beginner ,
Nov 13, 2018 Nov 13, 2018

Thanks for your help on the script and reference materials.  Any idea what is causing the output box (0.0348) to produce a shadow behind it?

var v1 = this.getField("J10").valueAsString;

var v2 = this.getField("K10").valueAsString;

var v3 = this.getField("L10").valueAsString;

var v4 = this.getField("M10").valueAsString;

if (v1=="" || v2=="" || v3=="" || v4=="") event.value = "";

else event.value = Number(v1)*Number(v2)*((Number(v3)/100)*((100-Number(v4))/100)/2000);

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 ,
Nov 13, 2018 Nov 13, 2018

Maybe you've set the field to have a visible border line... Check under the field's Properties - Appearance.

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 Beginner ,
Nov 13, 2018 Nov 13, 2018

I have it set to no border is selected.

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 ,
Nov 13, 2018 Nov 13, 2018

Can you share the file with us (via Dropbox, Google Drive, Adobe Cloud, etc.)?

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 Beginner ,
Nov 13, 2018 Nov 13, 2018

https://1drv.ms/b/s!ArGxeXz2349JhpINdIU3WpkevpElwg

Sorry for the delay, here's the link to the form. The issue is for Question # 10 fields beyond the example, you will see some of the fields that show 0.0348. Your assistance is greatly appreciated! 

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 ,
Nov 14, 2018 Nov 14, 2018

It appears fine to me... This is what I see:

The issue with the fields in the last column is that you have multiple fields one on top of each other in rows 3-8.

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 Beginner ,
Nov 16, 2018 Nov 16, 2018
LATEST

It's fixed! Thanks for catching that, don't know how I missed it. Much appreciated!

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