Skip to main content
Known Participant
June 19, 2020
Question

Changing colour and locking text fields by clicking check box

  • June 19, 2020
  • 1 reply
  • 1939 views

Hi all

 

In interactive pdf forms is it possible to fill color in individual text fields basis certain criteria.  For example i have a text field which automatically fills a number basis conditions in a checkbox.

now i want this field to change colour also at the same time.  For better understanding please see below:

 

Text field - Score1

check box1

 

 

for now i have set the below script to get the desired value in Text field Score1 when the check box is clicked

 

if (event.target.value != "Off") {
this.getField("Score1").value = "60" ;
} else {
this.getField("Score1").value = "50" ;

now I want the text field to change colour to Red if i get 50 and to green if i get 60

please note that it is important that Text field Score1 is made non editable and change in colour stays permanent.

thanks for your help 

 

This topic has been closed for replies.

1 reply

JR Boulay
Community Expert
June 19, 2020
if (event.target.value != "Off") {
this.getField("Score1").value = "60" ;
this.getField("Score1").fillColor = color.green; } else { this.getField("Score1").value = "50" ;
this.getField("Score1").fillColor = color.red;
}
Acrobate du PDF, InDesigner et Photoshopographe
NKB0609Author
Known Participant
June 19, 2020

Thanks a lot for your response, much appreciate.  I have tried this code but the challenge is that if i click on the text box (Score1) color changes as scripted however if I click anywhere else, colour disappears.  Also is there a way to make this text box uneditable as i do not want the user to change the values.  Thanks for all your help. 

NKB0609Author
Known Participant
July 3, 2020

My bad, had to put it as validation script.

It works like charm try67.  You are a genius. 🙂


I have one more question on this topic.  Is there a way to make a text box change colour basis a combination of there other text box colours.

 

Now that above script works like a charm and i can get the desired colour in the text field dependent on values.

now i want to change the colour of a text field basis the output colour of these text fields.

 

For example

Text field 1 has above validation script and changes colour basis value

Text field 2 has above validation script and changes colour basis value

Text field 3has above validation script and changes colour basis value

 

i want text field 4 to change colour if suppose:

 

Text field 1= Red

Text field 2= Green

Text field 3 = Yellow

 

final text field 4 becomes Yellow

 

else

 

Text field 1= Red

Text field 2= Red

Text field 3 = Yellow

 

Text field 4 = Red 

 

else

and so on.....

will highly appreciate your help in this