Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Totaling a column of numbers derived with javascript and Reset a form not working

New Here ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

Hi,

 

I am two issues from completing my document.  

Issue one:

I need to total a column of numbers that are derived from fields with javascript behind them.  I have tried to use the calculation field and have checked the boxeds of fields I want totals of and I do not get an accurate figure.  Sometimes I get the message NaN (not a number).  Do I have to make this request with javascript and what would it look like?  Here is an example of the javascript I have behind one of the fields in the column to be totaled:

 

var v = this.getField("EDAssign01").valueAsString;

if (v=="HS - Activities Director") event.value = "5,705.00";

else if (v=="HS - All School Play - Director") event.value = "1,713.00";

else if (v=="HS - All School Play - Assistant Director") event.value = "914.00";  etc., etc

 

I have also attached a jpeg of what the form looks like.

 

Second Issue:

I have an action set up to "Reset a Form" on mouse up and have selected all of the fields in the document.  It will not reset the fields that have multichoice dropdowns in them....any suggestions.  

 

Thanks so much.  I have learned a tremendous amount of information doing this!!  

TOPICS
PDF forms

Views

527

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
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , May 24, 2021 May 24, 2021
A value like "5,705.00" is a formatted number string, it is not number, which is why you're getting NaN errors.  Change the script to apply pure numbers and do the formatting with the formatting feature of the fields.  There is no such a thing as a multichoice dropdown. 

Likes

Translate

Translate
Adobe Community Professional ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

A value like "5,705.00" is a formatted number string, it is not number, which is why you're getting NaN errors. 

Change the script to apply pure numbers and do the formatting with the formatting feature of the fields. 

 

There is no such a thing as a multichoice dropdown. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
community guidelines
Enthusiast ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

It would be easier if you could share your file with us?

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
community guidelines
New Here ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

Ok, thanks.  I have attached the pdf....

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
community guidelines
Adobe Community Professional ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

As Thom said you didn't format it correctly or to put it simple you were trying to calculate words.

Since there is a lot of data in those fields and to save you from rewriting it, I tried to use what you have to make it work.

See if it's what you wanted:

https://drive.google.com/uc?export=download&id=1KRqvKPu5oQOeRoNNRByJPQd19MU0WZ52 

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
community guidelines
New Here ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

It is perfect!!!  How and where did you do this??  It is awesome!!!

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
community guidelines
New Here ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

LATEST

Ok, I just saw the script you worked on in the total field. I can't thank you enough!!!

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
community guidelines