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

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

250

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

Copy link to clipboard

Copied

Did you use the code? Any problem with this?

Votes

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?

Votes

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

Copy link to clipboard

Copied

Any error message? Where does you place the code?

Votes

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.

Votes

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

Copy link to clipboard

Copied

Check the field calculation order.

Votes

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.

Votes

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

Copy link to clipboard

Copied

I have no more idea.

Votes

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
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.

Votes

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