These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

fields in an array ... (not sure how to define subject of post)

1stSniff
Registered: Jun 23 2009
Posts: 10
Answered

Hi folks ... I know that I am going to slap myself in the forehead on this one probably, but I just can't grasp this in my mind:

Case:
In my document, there are series of fields created by place multiple fields such as:
name.first.1
name.first.2

name.last.1
name.last.2, etc...

I understand that I can assign a function to a variable such as
var getFirst=this.getField("name.first.1");
var getLast=this.getField("name.last.1");

But ... here is where I think I am just being blind ...

How would I set up a variable/function that is more flexible by letting me assign the (index number?) via a passed variable?

Can I assign the fieldname minus the index to a variable?
var fname="name.first"+indexNo;

then .... var getFirst=this.getField(fname);

I hope that I explained this in a way that makes some sense ... and that it isn't a dumb question.

Thanks in advance!
-Scott

My Product Information:
Acrobat Pro 9.2, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2399
Yes, just how you did it... only you missed the last dot at the end of the name.
It should be:
var fname="name.first."+indexNo;

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

1stSniff
Registered: Jun 23 2009
Posts: 10
Perfect thank you!!!

Silly as it is, I think it started to make a little more sense as I tried to figure out how to explain it. Using this, I can then use a loop with the index variable as well now, right?

Thanks for you prompt response!
-Scott
try67
Expert
Registered: Oct 30 2008
Posts: 2399
Yes, but I didn't understand what you meant by "assign a function to a variable" in the original post.
I think you got your terminology a bit mixed up. You're assigning a field object to a variable, not a function.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com