Skip to main content
Participating Frequently
June 17, 2021
Question

Dropdown box selection to change background color of a different text field

  • June 17, 2021
  • 1 reply
  • 2891 views

Hello!

I have a client who likes to highlight rows on his to do list based on a certain type of task. Each type of task is a different color.

 

I would like to be able to create a dropdown with different color names in it and when a color is chosen, that row is highlighted in that color. I know how to do it with a button in the Indesign interactive PDF, but that makes the pdf too cluttered. My google-fu is failing me on how to do it with a dropdown list instead.

 

I have added a screenshot to show you what I have so far with the buttons.

I have the most recent version of Adobe Acrobat Pro.

 

I found this post on the forums but it doesn't explain how to change the color of a DIFFERENT field. 

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
June 17, 2021

Here is sample code you can work from, use it in "Dropdown" field validation script and in "Dropdown" field properties under 'options' tab check ' commit selected value immediately'.
You can adapt code to reset colors if needed and also you can use RGB colors since built in object have only few colors at disposal.

if(event.value == "Blue"){
this.getField("Row1.Field1").fillColor = color.blue;
this.getField("Row1.Field2").fillColor = color.blue;
this.getField("Row1.Field3").fillColor = color.blue;}
else if(event.value == "Yellow"){
this.getField("Row2.Field1").fillColor = color.yellow;
this.getField("Row2.Field2").fillColor = color.yellow;
this.getField("Row2.Field3").fillColor = color.yellow;}
else if(event.value == "Green"){
this.getField("Row3.Field1").fillColor = color.green;
this.getField("Row3.Field2").fillColor = color.green;
this.getField("Row3.Field3").fillColor = color.green;}