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

Script with multiple fields calculated and leave blank no data

Community Beginner ,
Nov 07, 2018 Nov 07, 2018

Copy link to clipboard

Copied

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

Views

311

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
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!

Likes

Translate

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

Copy link to clipboard

Copied

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);

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

Copy link to clipboard

Copied

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

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
community guidelines
Community Expert ,
Nov 07, 2018 Nov 07, 2018

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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);

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
community guidelines
Community Expert ,
Nov 13, 2018 Nov 13, 2018

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

I have it set to no border is selected.

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
community guidelines
Community Expert ,
Nov 13, 2018 Nov 13, 2018

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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! 

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
community guidelines
Community Expert ,
Nov 14, 2018 Nov 14, 2018

Copy link to clipboard

Copied

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.

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
community guidelines
Community Beginner ,
Nov 16, 2018 Nov 16, 2018

Copy link to clipboard

Copied

LATEST

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

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
community guidelines