Highlighted

Simple Fillable Form Calculation- Division

New Here ,
Oct 24, 2020

Copy link to clipboard

Copied

Hi,

I need my fillable form to automatically divide two sub-totals.  What is the javascript code that I need to place in the last line to get these two subtotals (Cash Availability/CashNeedsFor30Days) to divide?  Thank you in advance!  

Screen Shot 2020-10-24 at 6.30.36 PM.png

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Use this code as the custom calculation script:

 

var v1 = Number(this.getField("Cash Availability").valueAsString);
var v2 = Number(this.getField("Cash Needs for 30 Days").valueAsString);
if (v2==0) event.value = "";
else event.value = v1/v2;

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

72

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

Simple Fillable Form Calculation- Division

New Here ,
Oct 24, 2020

Copy link to clipboard

Copied

Hi,

I need my fillable form to automatically divide two sub-totals.  What is the javascript code that I need to place in the last line to get these two subtotals (Cash Availability/CashNeedsFor30Days) to divide?  Thank you in advance!  

Screen Shot 2020-10-24 at 6.30.36 PM.png

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Use this code as the custom calculation script:

 

var v1 = Number(this.getField("Cash Availability").valueAsString);
var v2 = Number(this.getField("Cash Needs for 30 Days").valueAsString);
if (v2==0) event.value = "";
else event.value = v1/v2;

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

73

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
Oct 24, 2020 0
Most Valuable Participant ,
Oct 24, 2020

Copy link to clipboard

Copied

Divide by what? 2? What's the name of the field that contains the sub-total you want to divide?

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
Reply
Loading...
Oct 24, 2020 0
New Here ,
Oct 24, 2020

Copy link to clipboard

Copied

Field Name "Cash Availability" divided by "Cash Needs for 30 Days".

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
Reply
Loading...
Oct 24, 2020 0
Most Valuable Participant ,
Oct 25, 2020

Copy link to clipboard

Copied

Use this code as the custom calculation script:

 

var v1 = Number(this.getField("Cash Availability").valueAsString);
var v2 = Number(this.getField("Cash Needs for 30 Days").valueAsString);
if (v2==0) event.value = "";
else event.value = v1/v2;

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
Reply
Loading...
Oct 25, 2020 0
New Here ,
Oct 25, 2020

Copy link to clipboard

Copied

Thank you so very much!!!  You saved me!

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
Reply
Loading...
Oct 25, 2020 0
Engaged ,
Oct 25, 2020

Copy link to clipboard

Copied

Write this in "Simplified Field Notation":  Cash\ Availability/CashNeedsFor30Days

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
Reply
Loading...
Oct 25, 2020 0
New Here ,
Oct 25, 2020

Copy link to clipboard

Copied

Unfortunately, this one wouldn't work for me.  I don't understand why, but it wouldn't divide the fields.  The above custom calculation script did the trick though.  Thank you for reaching out - 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
Reply
Loading...
Oct 25, 2020 0
Engaged ,
Oct 25, 2020

Copy link to clipboard

Copied

Thats because I thought  your field name is "CashNeedsFor30Days" but it's "Cash Needs for 30 Days"

the code should be: Cash\ Availability/Cash\ Needs\ for\ 30\ Days

It's better not to use spaces in field names if using SFN.

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
Reply
Loading...
Oct 25, 2020 0