Column totals automatically return specific words dependant on what the total is

New Here ,
Sep 13, 2018

Copy link to clipboard

Copied

I have a two page pdf form where the user puts a tick in the appropriate box.  At the bottom of the form, the ticks in each column are added up.  This sub-total (sub-total_1) is then multiplied by a specific number (column 1 is by 1, column 2 is by 2, column 3 is by 3 and column 4 is by 4) to give sub-total_2.  Both sub-totals 1 and 2 are then added to give a final total for each column.  All four column totals are then added to give a final figure.  All of this works.

Based on the final total, I would like the form to automatically write:

Low if the total is between 0 and 20;

Moderate if the total is between 21 and 33;

High if the total is between 34 and 46;

Extreme if the total is 47 or more.

Is this possible and, if so, how do I do that?

I'm using Adobe Acrobat Pro DC, 2015

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

As the custom calculation script of the text field where you want to show the result, enter this code:

var total = Number(this.getField("Total").valueAsString);

if (total<=20) event.value = "Low";

else if (total<=33) event.value = "Moderate";

else if (total<=46) event.value = "High";

else event.value = "Extreme";

PS. The entire first paragraph of your question was not really necessary... It's better to keep things simple, to increase your chances of getting a reply.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

121

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

Column totals automatically return specific words dependant on what the total is

New Here ,
Sep 13, 2018

Copy link to clipboard

Copied

I have a two page pdf form where the user puts a tick in the appropriate box.  At the bottom of the form, the ticks in each column are added up.  This sub-total (sub-total_1) is then multiplied by a specific number (column 1 is by 1, column 2 is by 2, column 3 is by 3 and column 4 is by 4) to give sub-total_2.  Both sub-totals 1 and 2 are then added to give a final total for each column.  All four column totals are then added to give a final figure.  All of this works.

Based on the final total, I would like the form to automatically write:

Low if the total is between 0 and 20;

Moderate if the total is between 21 and 33;

High if the total is between 34 and 46;

Extreme if the total is 47 or more.

Is this possible and, if so, how do I do that?

I'm using Adobe Acrobat Pro DC, 2015

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

As the custom calculation script of the text field where you want to show the result, enter this code:

var total = Number(this.getField("Total").valueAsString);

if (total<=20) event.value = "Low";

else if (total<=33) event.value = "Moderate";

else if (total<=46) event.value = "High";

else event.value = "Extreme";

PS. The entire first paragraph of your question was not really necessary... It's better to keep things simple, to increase your chances of getting a reply.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

122

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
Sep 13, 2018 0
Most Valuable Participant ,
Sep 14, 2018

Copy link to clipboard

Copied

As the custom calculation script of the text field where you want to show the result, enter this code:

var total = Number(this.getField("Total").valueAsString);

if (total<=20) event.value = "Low";

else if (total<=33) event.value = "Moderate";

else if (total<=46) event.value = "High";

else event.value = "Extreme";

PS. The entire first paragraph of your question was not really necessary... It's better to keep things simple, to increase your chances of getting a reply.

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...
Sep 14, 2018 1
New Here ,
Sep 16, 2018

Copy link to clipboard

Copied

Thankyou for helping me. I entered your code as the custom calculation

script of the text field where I want to show the result and nothing

happened.

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...
Sep 16, 2018 0
Adobe Community Professional ,
Sep 16, 2018

Copy link to clipboard

Copied

Check the JavaScript console for errors by pressing Ctrl+J.

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...
Sep 16, 2018 0
New Here ,
Sep 16, 2018

Copy link to clipboard

Copied

Turns out I had an upper case letter where it should have been lower case! (in the field name)

Thankyou so much to both of you for helping me!

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...
Sep 16, 2018 0