• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
Exit
• Divide and Round Up answer

# 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

Views

288

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
8 Replies 8
Community Expert ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

Did you use the code? Any problem with this?

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

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

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 Expert ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

Any error message? Where does you place the code?

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
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.

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 Expert ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

Check the field calculation order.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

The field calculation order is correct.

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 Expert ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

I have no more idea.

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 Expert ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

LATEST

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.