Copy link to clipboard
Copied
Hello,
I have a similar situation in which I'm trying to highlight specific sections when I choose a specific drop down option. Could you please help me out as well. Please see my example of my pdf form below.
I saw this script from this posting on forum and I want something similar to this:Solved: Conditional formatting of cell's fill based on tex... - Adobe Support Community - 10706981
My Adobe Acrobat Pro Form
Copy link to clipboard
Copied
In what way do you want to highlight them, exactly?
Copy link to clipboard
Copied
I would like to highlight the fields with either a red boarder or a fill to show which items need to be filled out.
Thank You 🙂
Copy link to clipboard
Copied
The concept is the same. Use a validation script on the dropdown to set the border color of the fields you want highlighted, depending on the selection.
Here's a template for how your code should look. Put this code in custom validation script for the dropdown. You'll need to change the field and list items names, and fill in the missing fields and selection options.
// First hide all field borders
this.getField("Field1").strokeColor = ["T"];
this.getField("Field2").strokeColor = ["T"];
... etc. (repeat for all affected fields)
// Next highlight the field borders, depending on the current selection
switch(event.value)
{
case "Selection#1":
this.getField("Field1").strokeColor = color.red;
this.getField("Field2").strokeColor = color.red;
break;
case "Selection#1":
this.getField("Field3").strokeColor = color.red;
this.getField("Field5").strokeColor = color.red;
break;
}
Copy link to clipboard
Copied
Thank you for your help, I will test this out later today and see if it works for me.
Copy link to clipboard
Copied
Could provide me a litte more detail on how it would look if I wanted to highlight one of the fields such as the first name.
Sorry I'm a noob at this. I appreciate any and all assistance.
Copy link to clipboard
Copied
Ok, so what is the name of the first name field? Everything about form fields is controlled through the name. Please be exact.
Take a look a this article:
https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm
Copy link to clipboard
Copied
Hi Sorry for the late response, the name of the first field would be one of the drop downs from "type of change" field. For instance if I choose cubicle option in the dropdown field I would like for the First Name, Last Name, User Id, and all of the other fields to be highlighted red for that specific choice.
Thank You
Copy link to clipboard
Copied
The script I posted goes into the Custom Validation Script for the Drop down field.
You don't need to know the name of that field becuase it's where the script goes. What you need is the name of the fields that are highlighted. In my script those fields are "Field1", "Field2", "Field3", and "Field5". For your fields the script would look like this:
// First hide all field borders
this.getField("Field1").strokeColor = ["T"];
this.getField("Field2").strokeColor = ["T"];
... etc. (repeat for all affected fields)
// Next highlight the field borders, depending on the current selection
switch(event.value)
{
case "cubicle":
this.getField("First Name").strokeColor = color.red;
this.getField("Last Name").strokeColor = color.red;
this.getField("User Id").strokeColor = color.red;
break;
case "Selection#1":
this.getField("Field3").strokeColor = color.red;
this.getField("Field5").strokeColor = color.red;
break;
}
But you have to be sure these are the actual names of the fields. In your post these are the text labels in front of the fields.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
That is correct, those are the field names. Is the script working?
Copy link to clipboard
Copied
Hi Thom for some reason I'm getting a SyntaxError am I doing something wrong?
Thank You
Copy link to clipboard
Copied
Remove the line that starts with "...", or add "//" (without the quotes) before it to comment it out, since it's not valid code.
Copy link to clipboard
Copied
The "... etc. (repeat for all affected fields)" is not code. It's just there to let you know you need to add in the code for the real fields on your form.
And, the code won't work unless you replace the fake field names in my code with the real field names on your form.
Copy link to clipboard
Copied
Hi Thom,
I may have to play with it more as I'm terrible with code 😄
For some reason I can't seem to get the code to interact with my form : /
I know its more user error than your actual code. Thank you for your patience thus far.
Copy link to clipboard
Copied
I would suggest that you spend some time learning Core JavaScript. It doesn't take much time to go over the beginner lessons. Just search and you'll find plenty, like this one:
https://www.w3schools.com/js/default.asp
And then you can learn about Acrobat JavaScript here: