Expand my Community achievements bar.

Nomination window for the Adobe Community Advisor Program, Class of 2025, is now open!
SOLVED

getField

Avatar

Level 2

I have seen code examples using getField

Wanted to try it: So I have a field on my form called nYear

But when I use this code

var nYear = this.getField("nYear").value;

I get the error

this.getField is not a function

2:XFA:myday[0]:Page1[0]:Button1[0]:click

Any ideas why?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

getField is an AcroForm function/script.

To access the value of an object, you can use .rawValue.

I would not be inclined to use the same name for a script variable and an object. So if the object was named 'yearInput' and the script variable 'nYear', the following javascript would achieve what you want:

var nYear = yearInput.rawValue; 

Good luck,

Niall

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi,

getField is an AcroForm function/script.

To access the value of an object, you can use .rawValue.

I would not be inclined to use the same name for a script variable and an object. So if the object was named 'yearInput' and the script variable 'nYear', the following javascript would achieve what you want:

var nYear = yearInput.rawValue; 

Good luck,

Niall