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

Need Help with Drop down menu

New Here ,
Aug 12, 2021 Aug 12, 2021

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

ADOBE EXAMPLE.png

 
 

 

TOPICS
Acrobat SDK and JavaScript

Views

594

Translate

Translate

Report

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 ,
Aug 12, 2021 Aug 12, 2021

Copy link to clipboard

Copied

In what way do you want to highlight them, exactly?

Votes

Translate

Translate

Report

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
New Here ,
Aug 16, 2021 Aug 16, 2021

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 🙂 

Votes

Translate

Translate

Report

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 ,
Aug 16, 2021 Aug 16, 2021

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;
}

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
New Here ,
Aug 27, 2021 Aug 27, 2021

Copy link to clipboard

Copied

Thank you for your help, I will test this out later today and see if it works for me.

 

Votes

Translate

Translate

Report

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
New Here ,
Aug 27, 2021 Aug 27, 2021

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. 

Votes

Translate

Translate

Report

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 ,
Aug 27, 2021 Aug 27, 2021

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

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
New Here ,
Sep 09, 2021 Sep 09, 2021

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 

Votes

Translate

Translate

Report

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 ,
Sep 09, 2021 Sep 09, 2021

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.  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
New Here ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

Hi Thom,

Is the image below what youre reffering to regarding the field names. 

Thank you for your help so far 🙂 

 

Votes

Translate

Translate

Report

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 ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

That is correct, those are the field names.  Is the script working?

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
New Here ,
Sep 13, 2021 Sep 13, 2021

Copy link to clipboard

Copied

smirkguy88_0-1631550402747.png

Hi Thom for some reason I'm getting a SyntaxError am I doing something wrong? 

 

Thank You 

Votes

Translate

Translate

Report

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 ,
Sep 13, 2021 Sep 13, 2021

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.

Votes

Translate

Translate

Report

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 ,
Sep 13, 2021 Sep 13, 2021

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. 

 

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
New Here ,
Sep 13, 2021 Sep 13, 2021

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. 

Votes

Translate

Translate

Report

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 ,
Sep 13, 2021 Sep 13, 2021

Copy link to clipboard

Copied

LATEST

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:

https://www.pdfscripting.com/

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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