Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Use script in 'Validate' tab, not 'Calculate'.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Understood! Thank you both for your responses, it is working as I had hoped now!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now