Copy link to clipboard
Copied
Hi all, first-time user, with zero experience in this. Embarrassing but way out of my depth. Wanting to have a script (Java?) for the following:
I have 3 columns in a fillable PDF. If the user selects a category drop-down from column one, I want the following two columns only to show what is relevant to that group. I watched endless videos and tried multiple scripts and keep failing with syntax error - illegal character 2: line 3 etc type messages. I am lost but need it to work.
I tried the following:
If (event.value == "Category")
this.getField("Category").setItems(["Clinical_Management", "Care_Delivery", "Communication", “Resources”, “Other”]);
{
}else if(event.value == "General_Factor")
this.getField("General_Factor").setItems([" 1. assessment", "2. Investigations"," 3. Diagnosis)", “ 4. Treatment”, “ 5. Escalation”, “6. Access ”, “ 7. Transfer”, “ 8. Medication”, “ 9. Care”, “10. Handover”, “11. Engagement”, “12. Documentation”, “13. Equipment”, “14. Work”, “1 5. Supervision”, 16. Policy”]);
}else this.getField("Specific_Factor_&_Number").clearItems();
this.getField("Specific_Factor_&_Number ").setItems(["1.1Delayed”, ”1.2 Inadequate”, “2.1 Not requested”, ”2.2 Delayed / Missing”, “2.3 Results not reviewed / not acted upon in time”, “3.1 Delayed”, “3.2 Incorrect / missed”, “4.1 Delayed”, “4.2 Incorrect / Inadequate”, “4.3 Unavailable on-site”, 5.1 Delayed request”, “5.2 Delayed response”, “5.3 Response inadequate”, “6.1 Delayed”, “6.2 Inappropriate environment/ ward”, “6.3 Not available locally”, “ 7.1 Delayed”, “7.2 Unable to transfer to appropriate team”, “7.3 Extensive delay to transfer (external processes”, “8.1 Prescribing error”, “8.2 Administration error”, “8.3 Error – other”, “9.1 No End of Life plan documented”, “9.2 CPR inappropriately commenced”, “10.1 Delayed”, “10.2 Inadequate”, “10.3 Did not occur”, “11.1 Inadequate to patient/carer/family”, “12.1 Documentation delayed/incomplete”, “13.1 Not available”, “13.2 Fault-user”, “13.3 Failure”, “14.1 Workforce numbers low”, “14.2 Work demand high”, “14.3 Multiple competing priorities”, “14.4 Workforce skill mix/experience/competence inadequate”, “14.5 Individual performance issue identified (not openly discussed in meeting)”, “14.6 Routine work left for after-hours teams”, “15.1 Working outside of level expected”, “15.2 Direct supervision not available or delayed”, “16.1 No procedure or guideline available locally”, “16.2 Procedure or guideline not known by staff”, “16.3 Procedure of guideline not followed”) ]);
{
else this.getField("Dropdown2").clearItems();
}
then tried other scripts and types but now I am just frustrated so PLEASE anyone that can help it would be so appreciated as I need to get this to work. Thanks in advance to anyone who has the time and patience to help me.
Working in Adobe Acrobat 22.0
Copy link to clipboard
Copied
You have been probably copy/paste text from text editors, so you got different quotes marks, so you got syntax error, see example from your script:
this.getField("Category").setItems(["Clinical_Management", "Care_Delivery", "Communication", “Resources”, “Other”])
Fix the red ones in your script.
EDIT:
You also didn't set up script correctly and have issues with curly brackets.
Can you explain the process how it should work because you have a lot of different fields, perhaps share file with us?
Copy link to clipboard
Copied
Hi Nesa, Three columns are on a PDF fillable. People choose from the first section so that means if they go to the next column only things related their first column choice will be visible. example below:
Fruit Red Fruits Strawberry - apple - tomato
Vegetables Orange vegetables Pumpkin - carrots - etc
Nuts Salted Macadameas - cashews - brazillian etc
Really appreciate the help
Copy link to clipboard
Copied
So second dropdown have only one choice? If you select 'Fruit" only "Red Fruits" should be in second field?
Copy link to clipboard
Copied
Sorry Nesa, I was showing three types of examples. Nothing is working so I am going to call it a day. It is so hard when you do not know what to type but know exactly what you want it to do. I so need a course. Maybe I can try something tomorrow. Have a nice day.
Copy link to clipboard
Copied
Use if not If
At the end you have a else without a if
Copy link to clipboard
Copied
Thanks Bernd for your note.
Copy link to clipboard
Copied
Sandy,
Nessa is correct that the code contains many simple errors. It looks like you have the right idea, but in order to make it work the code must first be organized/formatted in a way that makes it possible to read. Then you'll be able to easily identify and fix the errors.
Here is a great article on the topic. A lot of it is about HTML, but many of the examples use JavaScript, and all of it is useful since it is about how the code is visually presented:
https://developers.google.com/style/code-samples
Copy link to clipboard
Copied
Thanks so much, Thom for the excellent links. I will review the links. I have no idea what I am doing as it is my first time but will try to persevere with it. It was a colleague who suggested this community as I have a new Creative Cloud licence to use this site and so appreciate all the help after being thrown in the deep end. 🙂
Copy link to clipboard
Copied
You can get a sample JavaScript here:
https://gist.github.com/JoelGeraci/f14d5277b910d9714a509c98f28e1e4b