New Forum | Previous | Next | (P-PDF) Beginners
Topic: Re: Combo box tied to fields javascript question (Via Email)
Conf: (P-PDF) Beginners, Msg: 111540
From: prodok
Date: 5/15/2004 07:55 PM
Actually, there might be am even more efficient approach.
In the Acrobat JavaScript implementation, arrays work very well and are
very fast. Therefore, defining and initializing arrays at document
level is not such a bad thing, and it is very easy to maintain arrays
at document level too.
One thing which already could speed things up in comparision to the
instant array creation approach described here would be an implicit
array definition, which means that instead of a text string which then
gets chopped up into array elements (using the split() method) uses a
string which is already an array. that would look somewhat like this:
display option export value
"ALB" ["7601 Bluewater NW", "Albuquerque", "NM",
"87121", "505-833-9554"]
And then refer to the the individual elements of the export value.
The next speed-up (IMHO) would be using the popUpMenu() method, because
if it is "only" for selecting something, with no further display
information need, this approach would be faster than dealing with a
Combo Box field.
To prepare for that case, you would instead define your location array
as document level array, and keeping the information in a consistent
manner. In order to keep things together, you would create a
multi-dimensional array, where for example your address information is
formed as an array (such as above), and itself it is an element of the
locations array. Then you could build up the selection list
instantaneously, whenever you need it. You would then either return the
index of the element in the master array, and use that one to refer to
the individual pieces, or you would return the whole address array and
refer to that one.
If you can freely work with Acrobat 6, things got even easier, as you
now have a few more options with popup menus.
Also note that it is easier to organize information in a popup menu,
because it would allow for hierarchical menus, avoiding those annoying
long 1-dimensional combo boxes.
Hope, this can help.
Max Wyss
PRODOK Engineering
Low Paper workflows, Smart documents, PDF forms
CH-8906 Bonstetten, Switzerland
Phone: +41 1 700 29 21
Fax: +41 1 700 20 37
or +1 815 425 6566
e-mail: mailto:max@prodok.com
http://www.prodok.com
[ Building Bridges for Information ]
______________________
Shameless Plug:
My next conference appearances and workshops:
• Conference presentations at the 2004 Symposium of the BFMA, May 23
to
27 in Reno, Nevada (http://www.bfma.org) and pre-/post-conference
workshop, May 22/23 and 27, organized by essociates Group
(http://www.essociatesgroup.com/AdvancedAcrobatForms.htm)
• During the Symposium, I will be available to attendees for ad-hoc
consulting at a hourly basis; please contact me in private for
scheduling.
• And, as always, available for on-site
workshops/tutorials/consulting.
_________________________
> If I can make a suggestion, you could use a completely different
> approach
> that might be easier to manage.
>
> Add the options to your destination combo box as follows
>
> display option export value
> "ALB" "7601 Bluewater NW~Albuquerque, NM
> 87121~505-833-9554"
> "ATL" "1800 James Pkwy NW~Atlanta, GA
> 30369-9751~404-792-3126"
>
> etc....
>
> then use this basic JS to populate the other fields
>
> var des = this.getField('destination');
> var strt = this.getField('street');
> var csz = this.getField('citystatezip');
> var phn = this.getField('phone');
>
> var desArr = des.valueAsString.split("~")
>
> strt.value = desArr[0];
> csz.value = desArr[1];
> phn.value = des[2];
>
> Its another way of getting where you want to go without
> having to manage all those separate arrays !