Skip to main content
Inspiring
July 17, 2023
Question

cannot figure out why error

  • July 17, 2023
  • 3 replies
  • 727 views

I keep getting these errors. I've gone back and copied/pasted field names exactly, but can't correct. Any guidance greatly appreciated!
TypeError: this.getField(...) is null
11:Field:Mouse Up
TypeError: this.getField(...) is null
31:AcroForm:CkBxOR82040:Annot1:MouseUp:Action1
TypeError: this.getField(...) is null
11:AcroForm:CkBxOR82040:Annot1:MouseUp:Action1
TypeError: this.getField(...) is null
26:Field:Mouse Up

TypeError: this.getField(...) is null
55:AcroForm:CkBxOR82040:Annot1:MouseUp:Action1

 

Here's the checkbox field 'mouse-op javascript' I'm using.

 

if (event.target.value == "or") {

// box is checked
this.getField("RBCoOwnerResident82040").display = display.visible;
this.getField("RBCoOwnerCitizen82040").display = display.visible;
this.getField("RBCoOwnerHear82040").display = display.visible;
this.getField("RBCoOwnerType82040").display = display.visible;
this.getField("CoOwnerName82040").display = display.visible;
this.getField("CoOwnerPhone82040").display = display.visible;
this.getField("CoOwnerEmail82040").display = display.visible;
this.getField("CoOwnerSex82040").display = display.visible;
this.getField("CoOwnerDOB82040").display = display.visible;
this.getField("CoOwnerID82040").display = display.visible;
this.getField("CkBxSameMailAddress82040").display = display.visible;
this.getField("CoOwnerMailAddress82040").display = display.visible;
this.getField("CoOwnerMailCity82040").display = display.visible;
this.getField("CoOwnerMailState82040").display = display.visible;
this.getField("CoOwnerMailZipCode82040").display = display.visible;
this.getField("CkBxSameCoOwnerMailAddress82040").display = display.visible;
this.getField("CoOwnerPhysicalAddress82040").display = display.visible;
this.getField("CoOwnerPhysicalCity82040").display = display.visible;
this.getField("CoOwnerPhysicalState82040").display = display.visible;
this.getField("CoOwnerPhysicalZipCode82040").display = display.visible;
this.getField("CoOwnerSignature82040").display = display.visible;
this.getField("CoOwnerSignDate82040").display = display.visible;
this.getField("CoOwnerSignature84490").display = display.visible;
this.getField("CoOwnerSignature84491").display = display.visible;
}
else {

// box is unchecked

this.getField("RBCoOwnerResident82040").display = display.hidden;
this.getField("RBCoOwnerCitizen82040").display = display.hidden;
this.getField("RBCoOwnerHear82040").display = display.hidden;
this.getField("RBCoOwnerType82040").display = display.hidden;
this.getField("CoOwnerName82040").display = display.hidden;
this.getField("CoOwnerPhone82040").display = display.hidden;
this.getField("CoOwnerEmail82040").display = display.hidden;
this.getField("CoOwnerSex82040").display = display.hidden;
this.getField("CoOwnerDOB82040").display = display.hidden;
this.getField("CoOwnerID82040").display = display.hidden;
this.getField("CkBxSameMailAddress82040").display = display.hidden;
this.getField("CoOwnerMailAddress82040").display = display.hidden;
this.getField("CoOwnerMailCity82040").display = display.hidden;
this.getField("CoOwnerMailState82040").display = display.hidden;
this.getField("CoOwnerMailZipCode82040").display = display.hidden;
this.getField("CkBxSameCoOwnerMailAddress82040").display = display.hidden;
this.getField("CoOwnerPhysicalAddress82040").display = display.hidden;
this.getField("CoOwnerPhysicalCity82040").display = display.hidden;
this.getField("CoOwnerPhysicalState82040").display = display.hidden;
this.getField("CoOwnerPhysicalZipCode82040").display = display.hidden;
this.getField("CoOwnerSignature82040").display = display.hidden;
this.getField("CoOwnerSignDate82040").display = display.hidden;
this.getField("CoOwnerSignature84490").display = display.hidden;
this.getField("CoOwnerSignature84491").display = display.hidden;
}



This topic has been closed for replies.

3 replies

Bernd Alheit
Community Expert
Community Expert
July 18, 2023

You can get the information about the missing fields when you define following function:

function f_getField(name)
{
	var fld = this.getField(name);
	if (!fld) {
		console.show();
		console.println("Missing field: '" + name + "'");
	}
	return fld;
}

 

Use the function like this:

f = f_getField("RBCoOwnerResident82040");
if (f) f.display = display.visible;

 

Thom Parker
Community Expert
Community Expert
July 18, 2023

Can you post the form?

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Inspiring
July 20, 2023

Thank you Thom for your interest and your response. Apologize for not returning sooner. I finally just started over with a clean slate, checking each script as I go. Learning how to read the console though! Thank you again for taking your time to lend a helping hand!! Thanks for all you do here in the community!!! Just Awesome!!!!

Inspiring
July 17, 2023

Hi Try67; did that and also cut/pasted names directly into script. Nothing corrected the issue. Removed phone field fomat. Even substitued 'Date' fields with Text fields formatted with a date setting  mm/dd/yyyy. Also tried running the scripts individually. Nothing changed, still the errors I mentioned earlier. Other suggestions? Thanks in advance- kemper

try67
Community Expert
Community Expert
July 17, 2023

Those errors mean you specified an incorrect field name. Go to the number line indicated (11, 31, etc.) and check around it if any of the names you used are not typed correctly. Even a single character off (like "O" instead of "o", or a space) will cause it to fail.

Inspiring
July 20, 2023

Thank you Try67 for your response. Apologize for not returning sooner. I finally just started over with a clean slate, checking each script as I go. Learning how to read the console though! Thank you again for taking your time to lend a helping hand!! Awesome!!!