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

populating a javascript array from text fields

watson23
Registered: Mar 25 2008
Posts: 37
Answered

Hi,
could anyone please help me out on this one? I've 2 groups of text fields (all of which have the same name, e.g.: textField_X[0], textField_X[1] and so on, and textField_Y[0], textField_Y[1], and so on). What I want to do is to populate an empty 2-dimensional javascript array with the values kept in these text fields. Is it possible? If so - how? I'm totally new to javascript so please put it as simple as for a 3-year old kid.
Thanks in advance for your help
Regards
T.M.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Absolutely this is possible, and we can give you an idea of how to get started, however you'll need to learn a bit about JavaScript to make this work in your form.

There is no native (predefined) 2 Dimensional JavaScript array. That's because JS is designed to be flexible so that you can create any kind of array with a little coding effort.

Like this:

var My2DArray = []; // Create new 1-D array;

My2DArray[0] = []; // Add array as entry
My2DArray[1] = [];
...etc...

Now you've got a 2D array.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

watson23
Registered: Mar 25 2008
Posts: 37
Thanks for your reply but what I meant is: how to (dynamically) populate that kind of array with values kept in a group of text fields?
T.M.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There isn't any kind of automatic dynamic binding for this sort of thing. You have to write code to copy the values over.

For example:

var col1 = xfa.resolveNodes("form..textField_X[*]");
for(var i=0;i

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

watson23
Registered: Mar 25 2008
Posts: 37
Thank you so much - that's just what I was looking for :)