Divide and Round Up answer

New Here ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

I have two fields, field A and field B. Field A needs to be divided by Field B and the answer needs to be rounded up. Example: 2÷5=1

How can I code this?

var AA = this.getField(“UNITSWEEK”).value;

var BB = this.getField(“MAXDAYSWK”).value;

if (BB==0) event.value = "";

else event.value = Math.ceil (AA / BB);

}

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

70

Likes

translate

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
community guidelines
Adobe Community Professional ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

Did you use the code? Any problem with this?

Likes

translate

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
community guidelines
New Here ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

No, I cannot get it to work yet. Have any ideas?

Likes

translate

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
community guidelines
Adobe Community Professional ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

Any error message? Where does you place the code?

Likes

translate

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
community guidelines
New Here ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

I changed it to this under custom calculations:

var AA = this.getField(“UNITSWEEK”).value;

var BB = this.getField(“MAXDAYSWK”).value;

event.value = "";

if(Number(BB) != 0) {

event.value = AA / BB;

event.value = Math.ceil(event.value);

}

It accepts the code, but it is not functioning.

Likes

translate

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
community guidelines
Adobe Community Professional ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

Check the field calculation order.

Likes

translate

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
community guidelines
New Here ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

The field calculation order is correct.

Likes

translate

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
community guidelines
Adobe Community Professional ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

I have no more idea.

Likes

translate

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
community guidelines
Most Valuable Participant ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

If you've used the code you posted above it will not be accepted as it contains invalid quotation marks in the first two lines, so either what you posted is not the actual code you entered, or the code you entered was not actually accepted.

Likes

translate

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
community guidelines