Skip to main content
Participating Frequently
May 17, 2019
Question

Loop syntax

  • May 17, 2019
  • 3 replies
  • 295 views

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 has been closed for replies.

3 replies

Thom Parker
Community Expert
Community Expert
May 17, 2019

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

Like this

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

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Legend
May 17, 2019

What event is this connected to?

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

try67
Community Expert
Community Expert
May 17, 2019

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