Skip to main content
Participant
December 8, 2020
Question

How to populate multiple text boxes from one dropdown selection

  • December 8, 2020
  • 1 reply
  • 790 views

Hi there

I am trying to populate two text boxes on a form triggered by one selection from a dropdown list.

Each dropdown selection has two attributes that I want to display, with one of them able to be overwritten.

My knowledge is limited but I have managed to get it to work for one attribute running this script on the 'Colour' dropdown Mouse up trigger:-

 

this.getField("Colour").setItems(new Array(

["",""],

["Black","1995"],

["White","1993"],

["Grey","1998"]

));

 

And adding this custom calculation script to the 'Year' text box:-

event.value=this.getField("Colour").value

(This variable is fixed and can’t be changed by the user).

 

I'd like to populate a second text box ‘Percentage’, with a colour attribute value (0.75%, 0.50%, 0.00% respectively), that could be overwritten by the user.

I thought I could just extend the array to cover a third variable but I can't make that work.

Can anyone guide me with how to do this?

Many thanks

 

 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
December 8, 2020

You can put multiple values in the second variable, separated by a known delimiter (such as "~" or ";") and then use the split method to split that single string into an array of strings, and apply each part to a different field.

 

If you're interested, I've created a (paid-for) tool that allows you to set up such a field much more easily, without having to write any code. See: http://try67.blogspot.com/2015/07/acrobat-populate-fields-from-dropdown.html

You can also get it from my new web-site, where's there's currently a "soft launch" sale (The discount code is available on the front-page):
https://www.try67.com/tool/acrobat-populate-fields-from-dropdown