Highlighted

Custom Script to only show when over 0

New Here ,
Nov 05, 2020

Copy link to clipboard

Copied

I'm new to customizing at this level. I want to calculate a field to add other fields (i know how to do this part) but I only want it to show if its over 0. 

a+b+c=d 

if a b and c are blank or 0 I want d to stay blank. 

TOPICS
How to, PDF forms

Views

62

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

Custom Script to only show when over 0

New Here ,
Nov 05, 2020

Copy link to clipboard

Copied

I'm new to customizing at this level. I want to calculate a field to add other fields (i know how to do this part) but I only want it to show if its over 0. 

a+b+c=d 

if a b and c are blank or 0 I want d to stay blank. 

TOPICS
How to, PDF forms

Views

63

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
Nov 05, 2020 0
Engaged ,
Nov 05, 2020

Copy link to clipboard

Copied

Something like this:

if(a == "" && b == "" && c == ""){

d = "";}

change "d" to event.value if you use code in "d" field.

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 05, 2020 0
Adobe Community Professional ,
Nov 05, 2020

Copy link to clipboard

Copied

Nesa I think you forgot to add a condition to handle when the value is less than or equal to 0 (like  a negative number).

 

 

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 05, 2020 1
Adobe Community Professional ,
Nov 05, 2020

Copy link to clipboard

Copied

I understood the question the same way as B.A.S.I.C.S

 

If yes, I was thinking of something like this:

 

var a = Number(this.getField("a").value);
var b = Number(this.getField("b").value);
var c = Number(this.getField("c").value);
var d = a+b+c;

event.value =""; 

if ( (a != "") && ( b != "") && (c != "") ) {event.value = d}

if (d <= 0 ) {event.value =""} 

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 05, 2020 0
Engaged ,
Nov 05, 2020

Copy link to clipboard

Copied

Hi, ls_rbls I wasn't making a full code, just an example to push him into right direction. My english is limited but from what I understand, he just want d field to be empty if other fields are empty or 0? 

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 05, 2020 0
Community Beginner ,
Nov 05, 2020

Copy link to clipboard

Copied

var a = Number(this.getField("a").value);
var b = Number(this.getField("b").value);
var c = Number(this.getField("c").value);
var d = a+b+c;

if (d = 0 ) {event.value =""}
else {event.value = a+b+c}

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 05, 2020 1
Most Valuable Participant ,
Nov 05, 2020

Copy link to clipboard

Copied

Change:

if (d = 0 )

To:

if (d == 0 )

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 05, 2020 0
try67 LATEST
Most Valuable Participant ,
Nov 05, 2020

Copy link to clipboard

Copied

And also:

event.value = a+b+c

To:

event.value = d

(this is not an error, just makes more sense...)

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 05, 2020 1
Community Beginner ,
Nov 05, 2020

Copy link to clipboard

Copied

To clarify, you want D to be hidden if the sum of A, B, and C = 0 or if they are all blank.  

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 05, 2020 0