Skip to main content
Participant
January 22, 2025
Question

java script for auto filling text boxes when drop down selection is made

  • January 22, 2025
  • 1 reply
  • 201 views

I am unable to get text boxes to populate using adobe and the below jave script. I'm attaching a loom vidoe for you to review. 

https://www.loom.com/share/4301ffc5af2d454a9b4457d324fbf43c?sid=d023e4bf-22f4-4adf-b6f6-8bd1f5697a17

var dropdownValue = this.getField("Dropdown1").value;

switch (dropdownValue) {
case "1.5":
this.getField("Text1").value = "ML180UH045E36A"
this.getField("Text2").value = "CK40HT-24A-071A"
this.getField("Text3").value = "ML14KC1-018"
break;

case "2":
this.getField("Text1").value = "ML180UH045E36A"
this.getField("Text2").value = "CK40HT-24A-071A"
this.getField("Text3").value = "ML14KC1-024"
break;

case "2.5":
this.getField("Text1").value = "ML180UH070E36B"
this.getField("Text2").value = "CK40HT-30B-071"
this.getField("Text3").value = "ML14KC1-030"
break;

case "3":
this.getField("Text1").value = "ML180UH070E36B"
this.getField("Text2").value = "CK40HT-42B-71"
this.getField("Text3").value = "ML14KC1-036"
break;

case "3.5":
this.getField("Text1").value = "ML180UH090E60C"
this.getField("Text2").value = "CK40HT-42C-071"
this.getField("Text3").value = "ML14KC1-042"
break;

case "4":
this.getField("Text1").value = "ML180UH090E60C"
this.getField("Text2").value = "CK40HT-51/61C-71"
this.getField("Text3").value = "ML14KC1-047"
break;

case "5":
this.getField("Text1").value = "ML180UH090E60C"
this.getField("Text2").value = "CK40HT-51/61C-71"
this.getField("Text3").value = "ML14KC1-059"
break;

default:
this.getField("Text1").value = ""
this.getField("Text2").value = ""
this.getField("Text3").value = ""
break;
}

1 reply

PDF Automation Station
Community Expert
Community Expert
January 22, 2025

In your first line, change this.getField("Dropdown1").value; to event.value;

Participant
January 22, 2025

I can not begin to tell you thank you enough! I have been working on this for hours. Thank you very much! It worked. 

PDF Automation Station
Community Expert
Community Expert
January 22, 2025

You're welcome.  TIP:  If you reference the value of another field in a custom calculation script, name the field with this.getField("FieldName").value.  If you reference the value of the field containing the calculation script, use event.value.