Highlighted

Limit max value

Community Beginner ,
Aug 25, 2020

Copy link to clipboard

Copied

Hi, I'm having little trouble with my code.

What i want to achive is, if value is greater then 66, value need to be 66.

Field is formated as percentage.

Here is what I got so far:

var HP = this.getField("HP").value;
var P = this.getField("Protection").value;
var W = this.getField("Ward").value;
var result = 1-(HP+W)/(HP+W+P);
if(P == 0){
event.value = 0;
}else if(event.value > 66){
event.value = 66;
} else event.value = result;

Everything is working as intended except it doesn't show 66 if value is greater.

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

Compare result with 66, not event.value.

TOPICS
Acrobat SDK and JavaScript

Views

21

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

Limit max value

Community Beginner ,
Aug 25, 2020

Copy link to clipboard

Copied

Hi, I'm having little trouble with my code.

What i want to achive is, if value is greater then 66, value need to be 66.

Field is formated as percentage.

Here is what I got so far:

var HP = this.getField("HP").value;
var P = this.getField("Protection").value;
var W = this.getField("Ward").value;
var result = 1-(HP+W)/(HP+W+P);
if(P == 0){
event.value = 0;
}else if(event.value > 66){
event.value = 66;
} else event.value = result;

Everything is working as intended except it doesn't show 66 if value is greater.

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

Compare result with 66, not event.value.

TOPICS
Acrobat SDK and JavaScript

Views

22

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
Aug 25, 2020 0
Adobe Community Professional ,
Aug 25, 2020

Copy link to clipboard

Copied

Compare result with 66, not 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...
Aug 25, 2020 0
Blaž LATEST
Community Beginner ,
Aug 25, 2020

Copy link to clipboard

Copied

Thanks

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...
Aug 25, 2020 0