Skip to main content
Participating Frequently
April 30, 2025
Answered

Looking for one Drop-Down with multiple bits of data

  • April 30, 2025
  • 3 replies
  • 1733 views

Hello Everyone,

 

I looking for one Drop-Down with multiple bits of data sent to different fields. 

Example: 

Vehicle 1 (the drop-down selection)

Stats about the vehicle: 3000 pds, 2 axels, & Red

 

I am looking for the different stats, to go to different fields after the seletion from the drop down is done.

 

Any assistance would be great, and thank you in advance.

Correct answer Nesa Nurani

@ls_rbls 

 

I'm still trying to make this work, sadly...


I read though your info a couple times, and checked around on-line a bit before coming back as I really want to understand what I did wrong. I updated the field names so its make a little more sense.


I'm starting with these field fake fields to get the hang of things, because in the end there will be 20+ fields, with 50+ vehicles of information. So I want to make this work so I can use the actual information in the future.

 

So on my last attempt, The data came back as undefined. Can you assist please?

 

 

var vehicleData = {

  "Vehicle 1": { WeightField: "3000 lbs", AxleField: "2", ColorField: "Red" },

  "Vehicle 2": { WeightField: "4000 lbs", AxleField: "3", ColorField: "Blue" },

  "Vehicle 3": { WeightField: "2500 lbs", AxleField: "1", ColorField: "Green" }

};

 

var selectedName = this.getField("VehicleDropdown").value;

 

if (vehicleData[selected]) {

  this.getField("WeightField").value = vehicleData[selected].weight;

  this.getField("AxleField").value = vehicleData[selected].axles;

  this.getField("ColorField").value = vehicleData[selected].color;

} else {

  this.getField("WeightField").value = "";

  this.getField("AxleField").value = "";

  this.getField("ColorField").value = "";

}


Use this as validate script of dropdown field:

var vehicleData = {
  "Vehicle 1": { WeightField: "3000 lbs", AxleField: "2", ColorField: "Red" },
  "Vehicle 2": { WeightField: "4000 lbs", AxleField: "3", ColorField: "Blue" },
  "Vehicle 3": { WeightField: "2500 lbs", AxleField: "1", ColorField: "Green" }
};

var data = vehicleData[event.value] || { WeightField: "", AxleField: "", ColorField: "" };

this.getField("WeightField").value = data.WeightField;
this.getField("AxleField").value = data.AxleField;
this.getField("ColorField").value = data.ColorField;

3 replies

PDF Automation Station
Community Expert
April 30, 2025
ls_rbls
Community Expert
May 1, 2025

I love that tutorial @PDF Automation Station , freaking amazing!!! 

Community Manager
April 30, 2025

Hi @ShifftyGuy

 

 

You can absolutely achieve this in Adobe Acrobat using JavaScript. The idea is to use a dropdown menu (for example, listing vehicles), and then use a script to populate other fields (like weight, axles, and color) based on the selected value.

 

Note: Adobe doesn't provide support for JavaScript unless you have a developer support contract. 

Here’s how you can do it:

1. Create the dropdown field

  • Name it something like VehicleDropdown

  • Add options like:

    • Vehicle 1

    • Vehicle 2

    • Vehicle 3

     

2. Create the fields to receive data

  • WeightField

  • AxleField

  • ColorField

3. Add JavaScript to the dropdown (On Blur or On Mouse Exit)

  1. Right-click on the dropdown > Properties

  2. Go to the Format tab and select None

  3. Go to the Actions tab:

    • Select Run a JavaScript on On Blur

    • Click Add… and paste this example script:

     

var vehicleData = {

  "Vehicle 1": { weight: "3000 lbs", axles: "2", color: "Red" },

  "Vehicle 2": { weight: "4000 lbs", axles: "3", color: "Blue" },

  "Vehicle 3": { weight: "2500 lbs", axles: "2", color: "Green" }

};

 

var selected = this.getField("VehicleDropdown").value;

 

if (vehicleData[selected]) {

  this.getField("WeightField").value = vehicleData[selected].weight;

  this.getField("AxleField").value = vehicleData[selected].axles;

  this.getField("ColorField").value = vehicleData[selected].color;

} else {

  this.getField("WeightField").value = "";

  this.getField("AxleField").value = "";

  this.getField("ColorField").value = "";

}

 

Note

  • Make sure the field names match exactly (case-sensitive).

  • You can add more vehicles and stats by extending the vehicleData object.

  • Use the On Blur event or On Mouse Exit to trigger the logic after selection.

 

 


~Tariq

Participating Frequently
May 1, 2025

@Tariq Ahmad 

Thank you very much for the quick reply, perfect break down and step by steps.

 

I applied everything you gave me and it only worked on one vehicle sometimes. Here is the code I used. Did I make a mistake somewhere?

 

var cList = {
"Vehicle 1": { color: Red, axel: 2, weight: 2050 },
"Vehicle 2": { color: Yellow, axel: 2, weight: 2050 },
"Vehicle 3": { color: Black, axel: 3, weight: 7452 }
};

var f1 = this.getField("color");
var f2 = this.getField("axel");
var f3 = this.getField("weight");
var selectedName = event.value;

if (cList[selectedName]) {
f1.value = selectedName;
f2.value = cList[selectedName].color;
f3.value = cList[selectedName].axel;}
f4.value = cList[selectedName].weight;}

else {
f1.value = "";
f2.value = "";
f3.value = "";}

Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
May 2, 2025

@ls_rbls 

 

I'm still trying to make this work, sadly...


I read though your info a couple times, and checked around on-line a bit before coming back as I really want to understand what I did wrong. I updated the field names so its make a little more sense.


I'm starting with these field fake fields to get the hang of things, because in the end there will be 20+ fields, with 50+ vehicles of information. So I want to make this work so I can use the actual information in the future.

 

So on my last attempt, The data came back as undefined. Can you assist please?

 

 

var vehicleData = {

  "Vehicle 1": { WeightField: "3000 lbs", AxleField: "2", ColorField: "Red" },

  "Vehicle 2": { WeightField: "4000 lbs", AxleField: "3", ColorField: "Blue" },

  "Vehicle 3": { WeightField: "2500 lbs", AxleField: "1", ColorField: "Green" }

};

 

var selectedName = this.getField("VehicleDropdown").value;

 

if (vehicleData[selected]) {

  this.getField("WeightField").value = vehicleData[selected].weight;

  this.getField("AxleField").value = vehicleData[selected].axles;

  this.getField("ColorField").value = vehicleData[selected].color;

} else {

  this.getField("WeightField").value = "";

  this.getField("AxleField").value = "";

  this.getField("ColorField").value = "";

}


Use this as validate script of dropdown field:

var vehicleData = {
  "Vehicle 1": { WeightField: "3000 lbs", AxleField: "2", ColorField: "Red" },
  "Vehicle 2": { WeightField: "4000 lbs", AxleField: "3", ColorField: "Blue" },
  "Vehicle 3": { WeightField: "2500 lbs", AxleField: "1", ColorField: "Green" }
};

var data = vehicleData[event.value] || { WeightField: "", AxleField: "", ColorField: "" };

this.getField("WeightField").value = data.WeightField;
this.getField("AxleField").value = data.AxleField;
this.getField("ColorField").value = data.ColorField;
Nesa Nurani
Community Expert
April 30, 2025
Participating Frequently
May 1, 2025

Thank you. I will take a look at this also.