Form Total not updating. Read all the posts....

Explorer ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

I successfully created a form with multiple lines, each of which calculate the total hours to 1 decimal place between two Date&Time Fields (m/d/yy HH:MM) and then multiply the Hours by a Rate that is pulled from a dropdown box. The line total is then shown in the right most column.

I have a simple formula to totals all the lines at the bottome but after checking the calculation order, etc, it still will not update correctly. I have read all the posts regarding sum uodates but it seems everyone has a different approach and I still ca't get it to total correctly. I'll attach screen shots of the form and the scripts.

Any help would be greatly appreciated as I was only able to complete the form to this point using all the help I previously received. Again thanks to those who reached out and helped.

Screen Shot 2021-03-30 at 6.21.21 PM.pngScreen Shot 2021-03-30 at 6.20.25 PM.pngScreen Shot 2021-03-30 at 6.19.41 PM.pngScreen Shot 2021-03-30 at 6.19.08 PM.png

TOPICS
How to, JavaScript, PDF forms

Views

329

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

Adobe Community Professional , Mar 31, 2021 Mar 31, 2021
You need to fix calculation order and one of the fields was named wrong, "Total 11" should be "Total11"I made changes check if it works now for you:https://drive.google.com/uc?export=download&id=1jQNIgJ0k2tq8DskWSs3LHOnfjYTyagsa  

Likes

translate

Translate

Translate
Adobe Community Professional ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

If you get rid of the current script in the "TotalTrip" field, and just use the built-in SUM feature it calculates correctly.

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
Explorer ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Thanks for the quick response. That is actually how I started out and it did not update so I tried what’s in there now. I can try again but it didn’t work before.

Thanks,
Bob

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
Adobe Community Professional ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Well, NesaNurani's answer complements what Bernd Alheit and JR Boulay are also suggesting.

 

In addition to those suggestions, this worked for me without the field name mispelling that NesaNurani pointed out.

 

But then, when I opened the console to check for errors, I also noticed the same "field is null" error as the screenshot provided by JR.

 

That makes sense with the incorrect spelling of a field object name.

 

The script will try to execute but then it stalls  if a field name in the script doesn't match the actual name of the field object that the script is expecting to be  referenced to.

 

By getting rid of the script and using the SUM built-in feature it didn't threw anymore errors and was calculating good.

 

I also noticed that you had all of the fields font size properties set to auto.

 

The TotalTrip text field was set with a font size of 12 pts.

 

Maybe this is relevant or not, but the font size was too big in contrast to the actual width and height of the text field object.

 

In the past, I've observed in my PDFs that if a font size is cut off (due to the dimensions of the text field itself), it will throw erronous results, specifically with date field objects that have custom calculating scripts in them (or used for other calculations accross that document).

 

So I changed all the fields' font size to 10pts including the TotalTrip field and that seemed to work for me.

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
Adobe Community Professional ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Change the field calculation order.

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
Adobe Community Professional ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

You should use the JS Console: https://acrobatusers.com/tutorials/javascript_console/

 

Capture_278.png

 

Capture_279.png

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
Adobe Community Professional ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

You need to fix calculation order and one of the fields was named wrong, "Total 11" should be "Total11"

I made changes check if it works now for you:

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

 

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