Skip to main content
pritym42174092
Participant
July 21, 2016
Answered

How do I change the background color of textField2 based on the value entered in textField1(Acrobat DC)?

  • July 21, 2016
  • 2 replies
  • 1218 views

Could you please help me solve this issue (I'm new to adobe acrobat dc):

Javascript written in textfield1(Color1) - Actions:

var C1 = this.getField("Color1");

var S1 = this.getField("Swatch1");

switch (C1.rawValue)

{

  case "PMS 100":

  S1.border.fill.color.value = "0,174,239";

     break;

  case "PMS 101":

  S1.border.fill.color.value = "236,0,140";

     break;   

}

This topic has been closed for replies.
Correct answer JR Boulay

Hi.

You can use this JavaScript (not tested) as a calculation script in the textfield2:

var myField = this.getField("textField1");

if (myField.valueAsString == "AAA") {event.target.fillColor = color.red;}

else if (myField.valueAsString == "BBB") {event.target.fillColor = color.blue;}

else if (myField.valueAsString == "CCC") {event.target.fillColor = color.black;}

// etc.

2 replies

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
July 22, 2016

Hi.

You can use this JavaScript (not tested) as a calculation script in the textfield2:

var myField = this.getField("textField1");

if (myField.valueAsString == "AAA") {event.target.fillColor = color.red;}

else if (myField.valueAsString == "BBB") {event.target.fillColor = color.blue;}

else if (myField.valueAsString == "CCC") {event.target.fillColor = color.black;}

// etc.

Acrobate du PDF, InDesigner et Photoshopographe
pritym42174092
Participant
July 22, 2016

Thank you

Bernd Alheit
Community Expert
Community Expert
July 21, 2016

Is this a form created with LiveCycle Designer?

pritym42174092
Participant
July 21, 2016

I'm trying to create form with acrobat dc not life cycle designer. I was able to create this in life cycle designer. But it doesn't work in acrobat dc.

Bernd Alheit
Community Expert
Community Expert
July 22, 2016

Don't use JavaScript for Designer. Use JavaScript for Acrobat.