Highlighted

Having a cell not populate without specific data

New Here ,
Sep 03, 2020

Copy link to clipboard

Copied

I have a total field for a simple calculation from data from two other fields.     What I'm trying to do is have the total field not populate if one of the two data fields doesn't have data.   I would like also for the total field to be greyed when total = 0 or less.

For calculation you can use this:

var a = this.getField("Text1").value;
var b = this.getField("Text2").value;
if(a == "" || b == ""){
event.value = "";}
else event.value = a+b;

 

For grey out , you want border and fill color (or just fill color) to be grey if value <= 0? And what color should it normaly be?

TOPICS
Acrobat SDK and JavaScript, How to

Views

46

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

Having a cell not populate without specific data

New Here ,
Sep 03, 2020

Copy link to clipboard

Copied

I have a total field for a simple calculation from data from two other fields.     What I'm trying to do is have the total field not populate if one of the two data fields doesn't have data.   I would like also for the total field to be greyed when total = 0 or less.

For calculation you can use this:

var a = this.getField("Text1").value;
var b = this.getField("Text2").value;
if(a == "" || b == ""){
event.value = "";}
else event.value = a+b;

 

For grey out , you want border and fill color (or just fill color) to be grey if value <= 0? And what color should it normaly be?

TOPICS
Acrobat SDK and JavaScript, How to

Views

47

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
Sep 03, 2020 0
Engaged ,
Sep 03, 2020

Copy link to clipboard

Copied

For calculation you can use this:

var a = this.getField("Text1").value;
var b = this.getField("Text2").value;
if(a == "" || b == ""){
event.value = "";}
else event.value = a+b;

 

For grey out , you want border and fill color (or just fill color) to be grey if value <= 0? And what color should it normaly be?

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...
Sep 03, 2020 1
New Here ,
Sep 03, 2020

Copy link to clipboard

Copied

Thank you, much apprieciated.

 

I would like it to be just fill color.  It's normally white and would like it to be grey when not populated.

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...
Sep 03, 2020 0
Contributor ,
Sep 03, 2020

Copy link to clipboard

Copied

And what if value is empty what color then

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...
Sep 03, 2020 0
Engaged ,
Sep 03, 2020

Copy link to clipboard

Copied

Add this to the code:

event.target.fillColor = event.value <= 0 || event.value == "" ? ["G",.7 ] : color.white;

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...
Sep 03, 2020 0
New Here ,
Sep 08, 2020

Copy link to clipboard

Copied

Thank you once again.

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...
Sep 08, 2020 0