Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Script for adding up numerous boxes across a document

Explorer ,
Dec 02, 2024 Dec 02, 2024

Is there any way of writing a script which might help me do this?

 

I have 40-odd pages of boxes and checkboxes. The boxes are under 5 different headings, and 3 different colours. So, for example the headings are  A, B, C, D, E and the boxes themselves may be coloured green, blue or orange.

 

I want to create a calculation which adds up the following:

Green boxes under Headings A-E

Orange boxes under Headings A-E

Blue boxes under Headings A-E

 

I appreciate I can do a calculation and add the individual check boxes, but right now I need to do that on 2 different screens as I can't see the list of field names along the right hand side when i'm trying to add them to the calculation. So I have to keep checking them and going back. Is there a quicker way to do this at all please? Ideally, I'd be able to see the field names where they appear in the document when I am adding them to the calculation. (I should have added the heading and colour when I started putting in the field names, but I didn't and I really can't do the whole thing again!)

 

Thanks.

TOPICS
JavaScript , PDF forms
1.2K
Translate
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
Community Expert ,
Dec 02, 2024 Dec 02, 2024

You can copy the fields names and then use the Simple Field Notation option under the Calculate tab to set up the sum, simply like this:

FieldA+FieldB+FieldC

etc.

However, if those field names contain a space you have to escape it, like this:

Field\ A+Field\ B+Field\ C

Translate
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 ,
Dec 02, 2024 Dec 02, 2024

Thanks very much. I've managed to put all the fields into the script but it adds up to 10 and goes no further, even though there are many more tasks than that. I have put in the \ instead of a space and also tried the \ AND a space, to no avail.

 

Having done a search, I also have changed all words into lower case.

 

I get this error:

 

 

SyntaxError: missing ; before statement
1:Field:Calculate
SyntaxError: missing ; before statement
1:Field:Calculate
SyntaxError: missing ; before statement
1:Field:Calculate
SyntaxError: illegal character
1:
SyntaxError: illegal character
1:
SyntaxError: illegal character
1:
SyntaxError: missing ; before statement
1:Field:Calculate
SyntaxError: missing ; before statement
1:Field:Calculate
SyntaxError: missing ; before statement
1:Field:Calculate
SyntaxError: missing ; before statement
1:Field:Calculate

 

The calculation is:

field\trigger.0.0.0+field\trigger.0.1+field\trigger.0.2+field\trigger.0.3+field\trigger.0.5+field\trigger.0.0.1.1+field\trigger.0.0.1.3+field\trigger.0.0.1.4+field\trigger.0.pg7+field\trigger.0.27+field\trigger.0.57.1.0.1.0+field\trigger.0.57.1.0.1.5+field\trigger.0.10.1+field\trigger.0.10.5+field\trigger.0.10.0.1.1+field\trigger.0.10.0.1.0.1.1.0+field\trigger.0.13.1+field\trigger.0.14.0.1+field\trigger.0.14.0.5+field\trigger.0.15.0.0.3+field\trigger.0.16.0.3+field\trigger.17.0.1.3+field\trigger.0.18.3+field\trigger.0.19.01.3+field\trigger.0.20.01.0.1+field\trigger.0.21.01.0.0.0+field\trigger.0.22.0+field\trigger.0.23.0+field\trigger.0.24.0+field\trigger.0.24.5+field\trigger.0.25.4+field\trigger.0.26.4+field\trigger.0.0.28.1+field\trigger.0.0.29.1+field\trigger.0.0.30.0+field\trigger.0.0.30.3+field\trigger.0.0.31.2+field\trigger.0.0.31.4+field\trigger.0.32.3+field\trigger.0.33.0+field\trigger.0.0.34.+field\trigger.0.0.35.0+field\trigger.0.0.35.4+field\trigger.0.36.0+field\trigger.0.0.37.2

 

Thank you for any advice you can give!

Translate
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
Community Expert ,
Dec 02, 2024 Dec 02, 2024

You're missing the actual spaces after the back-slashes.

Translate
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 ,
Dec 02, 2024 Dec 02, 2024

I put them in first, and when I got the "10" result I took them out, but that didn't change anything.

Translate
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
Community Expert ,
Dec 02, 2024 Dec 02, 2024

Well, you must put them if the field names actually contain a space. Can you share the file?

Translate
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 ,
Dec 03, 2024 Dec 03, 2024

I put the spaces back in but still had the same result. I would like to share the file but as it's work-related I don't think it'd be wise to share it publicly - would it be possible to share it privately with you at all please? Thank you again for your continued help.

Translate
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
Community Expert ,
Dec 03, 2024 Dec 03, 2024

Are you still getting console errors after following @try67 's instructions?

Translate
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 ,
Dec 03, 2024 Dec 03, 2024

Yes, that's what I got after following the instructions. I get the same result with or without adding a space.

Translate
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
Community Expert ,
Dec 02, 2024 Dec 02, 2024

Are these all check boxes and do they all have numbers as export values?

Translate
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 ,
Dec 03, 2024 Dec 03, 2024

Yes they do.

Translate
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 ,
Dec 03, 2024 Dec 03, 2024

Now something has gone majorly wrong as I'm trying to repair a formula in another unrelated cell and not only do I keep getting that Javascript message, when I try to select fields to add to the calculation none of them show. 😞 😞 😞 

Translate
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
Community Expert ,
Dec 03, 2024 Dec 03, 2024

Again, please share the file.

Translate
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 ,
Dec 03, 2024 Dec 03, 2024

As I said in response to your earlier message, this is a work document so I'm nervous about putting it on a public platform. Is there any way i can share it privately please? I am in such a mess, I don't know what on earth is going on.

Translate
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
Community Expert ,
Dec 03, 2024 Dec 03, 2024

You can email it to me, to try6767 at gmail dot com.

Translate
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 ,
Dec 03, 2024 Dec 03, 2024
LATEST

Thank you so much - winging over now!

Translate
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