Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Autofill form fields with dropdown list, but need flexibility to populate those fields manually

Community Beginner ,
May 22, 2025 May 22, 2025

Hello,

I have a PDF that has text fields that are autofilled based on a value that is selected in a dropdown list. The script looks something like this:

 

var dropdownValue = this.getField("Admission Type").value;

 

switch (dropdownValue) {

case "Type 1":

    this.getField("Requirement 1").value = "Waived"

    this.getField("Requirement 2").value = "Waived"

    this.getField("Requirement 3").value = "Waived"

    this.getField("Requirement 4").value = "Waived"

    this.getField("Requirement 5").value = "Waived" 

break;

 

case "Type 2":

    this.getField("Requirement 6").value = "OK, 60+"

    this.getField("Requirement 7").value = "OK, 60+"

    this.getField("Requirement 8").value = "OK, 60+"

break;

}

 

This is working fine; however, on rare occasions, I need the flexibility to manually type in other values for certain requirements.

 

For example, if completing my fillable form with "Type 1" selected from the dropdown list, I sometimes need to type in different information other than "Waived" for Requirement 4. The different information I would need to enter varies in most instances, so it would rarely ever be the same. When I try to do this with the current script, it will replace what I type in with "Waived", which makes complete sense. I am just unsure what I need to add to this script to allow me freedom to type in other values to Requirement 4, but still have it be "Waived" in most situations.

 

Is this something that can be done? Let me know if I need to elaborate any further. I am very new to all of this, so any assistance is greatly appreciated!

TOPICS
How to , JavaScript , Modern Acrobat , PDF , PDF forms
208
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
May 22, 2025 May 22, 2025

You also need to change this line:

var dropdownValue = this.getField("Admission Type").value;

To:

var dropdownValue = event.value;

 

In addition, you need to add a command to clear all the fields before applying new values. If you don't, and you change your selection, the values of the old fields will remain in place.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 22, 2025 May 22, 2025

Use script in 'Validate' tab, not 'Calculate'.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 22, 2025 May 22, 2025

You also need to change this line:

var dropdownValue = this.getField("Admission Type").value;

To:

var dropdownValue = event.value;

 

In addition, you need to add a command to clear all the fields before applying new values. If you don't, and you change your selection, the values of the old fields will remain in place.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 22, 2025 May 22, 2025
LATEST

Understood! Thank you both for your responses, it is working as I had hoped now!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines