I have a field that is the sum of 3 other fields. How do I leave the field blank if the value is zero?

Community Beginner ,
Oct 31, 2018

Copy link to clipboard

Copied

I have a field that is the sum of 3 other fields. How do I leave the field blank if the value is zero?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Are you using a script for the calculation, or something else?

If you're not using a script, you'll need to. The basic code to achieve it is:

var v1 = Number(this.getField("Text1").valueAsString);

var v2 = Number(this.getField("Text2").valueAsString);

var v3 = Number(this.getField("Text3").valueAsString);

var total = v1+v2+v3;

event.value = (total==0) ? "" : total;

TOPICS
Acrobat SDK and JavaScript

Views

107

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

I have a field that is the sum of 3 other fields. How do I leave the field blank if the value is zero?

Community Beginner ,
Oct 31, 2018

Copy link to clipboard

Copied

I have a field that is the sum of 3 other fields. How do I leave the field blank if the value is zero?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Are you using a script for the calculation, or something else?

If you're not using a script, you'll need to. The basic code to achieve it is:

var v1 = Number(this.getField("Text1").valueAsString);

var v2 = Number(this.getField("Text2").valueAsString);

var v3 = Number(this.getField("Text3").valueAsString);

var total = v1+v2+v3;

event.value = (total==0) ? "" : total;

TOPICS
Acrobat SDK and JavaScript

Views

108

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 31, 2018 0
Most Valuable Participant ,
Oct 31, 2018

Copy link to clipboard

Copied

Are you using a script for the calculation, or something else?

If you're not using a script, you'll need to. The basic code to achieve it is:

var v1 = Number(this.getField("Text1").valueAsString);

var v2 = Number(this.getField("Text2").valueAsString);

var v3 = Number(this.getField("Text3").valueAsString);

var total = v1+v2+v3;

event.value = (total==0) ? "" : total;

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 31, 2018 1
Community Beginner ,
Nov 01, 2018

Copy link to clipboard

Copied

Thank you worked like a charm.

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...
Nov 01, 2018 0