Skip to main content
Participating Frequently
May 17, 2019 2:08 PM UTC
Question

Loop syntax

is there any reason this code would not work on a button?

var f = this.getField("Installation");

var a = f.getArray()

for (i=0; i < a.length; i++){

    if (a.valueAsString != null) {

        createSheet();

    }

}

I have handfull fof filelds with installation in name and i'm checking to see if any of those fields have data.

This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

Thom Parker
Community Expert
Community Expert
May 17, 2019 7:00 PM UTC

"Installation" needs to be more than just in the name. It has to be a dotted prefix.

Like this

"Installation.text1", "Installation.text2", etc

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Legend
May 17, 2019 2:36 PM UTC

What event is this connected to?

What do you expect this code to do, and what does it do?

Translate
try67
Community Expert
Community Expert
May 17, 2019 2:17 PM UTC

Yes. If you access valueAsString it will never return null. If the field is empty it will return an empty string.

Translate