Want to map table data from a pulldown menu to various places in a document
I’m updating a form used for booking truck rentals. I’ve come up with a plan for the interactive elements. I have a couple holes in my knowledge and would like to ask for for some advice to help me complete it.
Here’s the situation. The client would like to have it where up to 30 trucks can be listed on the form, and each of the 30 trucks could be one of seven different models. The idea is to choose from a pull-down menu for each truck which has “NO TRUCK” as the default choice with the seven models as options. Once a model is chosen, there are eight data sets associated with each model that would be mapped to the truck rental number. That truck rental number’s data results will show up in various places in the forms.
The truck rentals are given names T01, T02, T03, etc… so their data sets are given a suffix in their fields like this…
T01d - Truck 1 depreciation value
T01v - Truck 1 original value
T01w - Truck 1 weekly fixed charge
… and so on for eight different sets.
The truck models have their data sets listed like this….
TD1d - (first model) depreciation value
TD2d - (second model) depreciation value
TD2v - (second model) original value
… and so on for all the models and all the data sets.
I want to be able for the appropriate model TD data sets to get mapped to the T01 to T30 data sets when the user uses the drop-down menu and picks a model.
And it seems to me that by using a document level script I could save a lot of hassle in editing. Someone here recommended that I should think that way for a future project and I haven’t forgotten. So I’m anticipating doing that and here’s how I thought it out…
My plan is that each dropdown menu would be fields labeled T01t, T02t, etc. Would it be possible to write a document level script that can:
- grab the first three characters of the current rental dropdown menu field name (ex.: T01) as a variable
- grab the first three characters of the chosen truck model field name (ex.: TD3) as a variable
- use those variables to join with a chosen fourth character to know which data sets to find
- map those data sets together and display them in the appropriate fields in the forms
My thought is that would allow a single document level script to do all the work of combining rentals with trucks and their data in various places on the form. Rental 1 would pick Truck model 3, and the script would know to grab Truck model 3’s data and map them to Rental 1’s spots on the various forms.
I’ve split path parts before and joined, but I’m not finding how to grab character parts here. I seem to see FieldName as something to work with.
Lastly, am I overthinking this and is there a simpler way? I’ve done three projects with javascript in Acrobat so I’m taking what I know from the limited experience I have and attempting something much bigger. But some advice would certainly be welcome. Thank you.
