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

TypeError: f is null

Community Beginner ,
Jan 27, 2021 Jan 27, 2021

Copy link to clipboard

Copied

I'm using the script described at Counting formula for checkboxes, but I'm receiving a "TypeError: f is null" error whenever I close the JavaScript Editor.

AFSimple_Calculate reveals that 

var f = this.getField(aFields[i]);

but that doesn't help me figure out what's going wrong. The only thing I've changed in the script is that I've changed "MyChecks" to "Points".

 

Help please? I'm using Acrobat 9 (yes, 9. Don't judge) on a Mac.

TOPICS
JavaScript

Views

2.6K

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 2 Correct answers

Community Expert , Jan 28, 2021 Jan 28, 2021

That means one of the field names you've entered is incorrect. Make sure you re-select the fields in your calculation after renaming or removing one of them, as the list doesn't update automatically when you do.

Votes

Translate

Translate
Community Expert , Feb 10, 2021 Feb 10, 2021

Sorry, I was looking at the total points field, not the number of objectives with points.

To fix that one change this part:

aCkFlds[i].isBoxChecked(0)

To:

aCkFlds[i].valueAsString!="Off"

Votes

Translate

Translate
Community Expert ,
Jan 28, 2021 Jan 28, 2021

Copy link to clipboard

Copied

That means one of the field names you've entered is incorrect. Make sure you re-select the fields in your calculation after renaming or removing one of them, as the list doesn't update automatically when you do.

Votes

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
Community Beginner ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

Alright, I think I figured that part out; thanks. But I'm having another difficulty.  I have three fields named Points.Q1, three named Points.Q2, etc. This is working great for its purpose: You can check one and only one of those fields. However, the counting script discussed here only counts when the first of the three identically-named fields in any set is checked. Is there a way around this problem? 

Votes

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
Community Expert ,
Feb 06, 2021 Feb 06, 2021

Copy link to clipboard

Copied

Can you post your code, or your actual file?

Votes

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
Community Beginner ,
Feb 09, 2021 Feb 09, 2021

Copy link to clipboard

Copied

Sure. Thanks.

Votes

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
Community Expert ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

Works fine for me.

Votes

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
Community Expert ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

Sorry, I was looking at the total points field, not the number of objectives with points.

To fix that one change this part:

aCkFlds[i].isBoxChecked(0)

To:

aCkFlds[i].valueAsString!="Off"

Votes

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
Community Beginner ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

LATEST

Thanks so much! That worked perfectly. I really need to sit down and learn Javascript.

Votes

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
Community Expert ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

Following

aCkFlds[i].isBoxChecked(0)

tests only the first checkbox of a group.

You must also test

aCkFlds[i].isBoxChecked(1)

and

aCkFlds[i].isBoxChecked(2)

Votes

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