Acrobat Form round a sum of two fields to the nearest 1/16th

New Here ,
Oct 06, 2017

Copy link to clipboard

Copied

I'am trying to round the sum of two fields in Adobe Acrobat to the closests 1/16th or 0.0625? I am not familiar enough with javascript to create a custom script.

paste this into the custom calculation script:

event.value = Math.round((Number(this.getField("A").value) + Number(this.getField("B").value))*16)/16;

You may want to set your format to Number, 4 decimals.

Image 1201.png

A longer javascript line that can also be pasted into the custom calculation script is:

this.getField("C").setAction('Calculate', "event.value = Math.round((Number(this.getField(\"A\").value) + Number(this.getField(\"B\").value))*16)/16;" );

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

403

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

Acrobat Form round a sum of two fields to the nearest 1/16th

New Here ,
Oct 06, 2017

Copy link to clipboard

Copied

I'am trying to round the sum of two fields in Adobe Acrobat to the closests 1/16th or 0.0625? I am not familiar enough with javascript to create a custom script.

paste this into the custom calculation script:

event.value = Math.round((Number(this.getField("A").value) + Number(this.getField("B").value))*16)/16;

You may want to set your format to Number, 4 decimals.

Image 1201.png

A longer javascript line that can also be pasted into the custom calculation script is:

this.getField("C").setAction('Calculate', "event.value = Math.round((Number(this.getField(\"A\").value) + Number(this.getField(\"B\").value))*16)/16;" );

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

404

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
Oct 06, 2017 0
Adobe Community Professional ,
Oct 06, 2017

Copy link to clipboard

Copied

How do you want the output to appear? For example, for a result of 3.1875, do you want that or "3 3/16", or something else?

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...
Oct 06, 2017 0
New Here ,
Oct 10, 2017

Copy link to clipboard

Copied

Decimals would be great, please.

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...
Oct 10, 2017 0
Engaged ,
Oct 06, 2017

Copy link to clipboard

Copied

paste this into the custom calculation script:

event.value = Math.round((Number(this.getField("A").value) + Number(this.getField("B").value))*16)/16;

You may want to set your format to Number, 4 decimals.

Image 1201.png

A longer javascript line that can also be pasted into the custom calculation script is:

this.getField("C").setAction('Calculate', "event.value = Math.round((Number(this.getField(\"A\").value) + Number(this.getField(\"B\").value))*16)/16;" );

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...
Oct 06, 2017 0
New Here ,
Oct 10, 2017

Copy link to clipboard

Copied

worked like a charm. Thank you.

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...
Oct 10, 2017 0