Need help to script a calculated fied

New Here ,
Jan 06, 2021 Jan 06, 2021

Copy link to clipboard

Copied

Hello here for a new topic!
I am still on my character sheet for one of my role-playing games and i need some calculations done in some fields of my form:

 

For example I would like in a field to appear:
(sum of several other fields) + 2  or  (sum of several other fields) - 10

I manage to calculate the sum of several fields without problem by going through Adobe Acrobat DC but i don't know how doing if my calculation is a little more complicated like adding 2 to the resultIs a Javascript script required ? 

Thank you for your help and advices

TOPICS
How to, Scripting

Views

73

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

correct answers 1 Correct Answer

Most Valuable Participant , Jan 06, 2021 Jan 06, 2021
You can use this calculation script:   var v1 = getField("field1").value;var v2 = getField("field2").value;var v3 = getField("field3").value;var v4 = 2;event.value = v1 + v2 + v3 + v4;

Likes

translate

Translate

Translate
Adobe Community Professional ,
Jan 06, 2021 Jan 06, 2021

Copy link to clipboard

Copied

If the adder for a given sum-of-fields is always the same (as in your example '+2'), you can do it without (having to write) javascript by adding a hidden, read-only text field with a value of 2 to the document, and include it in the fields named in your calculation.

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 ,
Jan 06, 2021 Jan 06, 2021

Copy link to clipboard

Copied

You can use this calculation script:

 

var v1 = getField("field1").value;
var v2 = getField("field2").value;
var v3 = getField("field3").value;
var v4 = 2;
event.value = v1 + v2 + v3 + v4;

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