I have a dynamic form that is going to have all manner of context sensitive drop down lists and values.
Background: This is a travel and subsistence form. Each mode of travel has its own set of costs and available fields dependent on the user's choice.
e.g Pick 'A - Air' and it should the Rate, Passenger, Equipment Carried, and Mileage fields but leave Fare open for input.
Pick 'C - Car' and then all of the above fields will be active including context specific entries for Rate (Standard(0.4), Lower Class(0.25), number of passengers (1, 0.05, 2, 0.1 etc) and so forth.
I have looked at Thom Parker's article (http://www.acrobatusers.com/tutorials/2007/js_list_combo_livecycle/) and example as a basis for a solution to this form but I'm not sure how I can use it with so many context sensitive fields involved.
A colleague has tried this before and had a different approach whereby he defined a set of variables and then detailed what values and access was needed for each variation. Where there were context senstive drop down lists these were defined separately.
Which is the most effective approach? Is there a different and more efficient way of doing this. I though maybe that linking to a spreadsheet of values may be a better way of doing this but am not sure whether this would be a viable option.
Any suggestions would be gratefully received.
In order to deal with changing list items on the fly you need to first identify how the items will be changing. Is it just one item at a time, or does the whole list change? What triggers the change? Is it a single change in another field, or are there a variety of things that could cause the field to change?
Then you have to create data structures that hold the items in a way that convenient and appropiate for the operation of the lists.
The example I provided in the first List article is for changing all of the items in the list from a single trigger. And it is the simplest and most effect method for dealing with this situation. A single object, defined in a global area, contains all of the different list item sets. Each item set is referenced with an identifier. In the code the identifier is acquired from a single source, i.e., another drop-down list.
Note however, that the code that actually makes the change in the list is placed in a function. This fucntion could be called from anywhere on the form. And the identifier doesn't have to be acquired from a single source, it could be found by examining several conditions on the form. So this one method provide a great deal of flexibilty.
The key pieces of the method are
1. All items in the drop-down list are changed at once.
2. There is an object based data structure defined for each drop-down.
3. This object contains all of the sets of list items that can be applied to that drop-down list.
4. Within each object, a particular set of list items is accessed with a single identifier.
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script