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

Divide and Round Up answer

New Here ,
Aug 06, 2019 Aug 06, 2019

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
414
Translate
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

Did you use the code? Any problem with this?

Translate
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

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

Translate
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

Any error message? Where does you place the code?

Translate
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

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.

Translate
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

Check the field calculation order.

Translate
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

The field calculation order is correct.

Translate
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

I have no more idea.

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

Translate
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