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

Text field color fill from multiple dropdowns

Community Beginner ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

Digital form 1.jpgexpand imageDigital form 2.jpgexpand imageDigital form 3.jpgexpand imageDigital form 4.jpgexpand imageI have an adobe form with 4 dropdown list. All 4 dropdowns have the same information. I am trying to get a text box to change the fill color based on the selection from the dropdown list regaurdless us whic one I use. I have managed to get this to work for the one of them but can't figure out the code for all 4.

TOPICS
JavaScript , PDF forms

Views

1.2K

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 ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

What script does you use?

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 Beginner ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

I used the below in in Custom calculation script.

 

var indicator = this.getField("STP-1").value; {

if (indicator=="Absent")

event.target.fillColor = color.green;

else if (indicator=="Tardy")

event.target.fillColor = color.green;

else if (indicator=="Exited")

event.target.fillColor = color.red;

else if (indicator=="Recycle")

event.target.fillColor = color.yellow;

else

event.target.fillColor = color.transparent;

event.target.fontColor = color.transparent;}

 

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 ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

What if one field has Tardy selected and another Recycled? Which color should be used then?

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 Beginner ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

Yellow regardless of the tardy, recycle would be the color through out the course.

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 ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

You need to explain the logic behind it, then. Which colors have precedence over which ones?

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 Beginner ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

It is an attendance sheet, if the partictpant is present for the fist half of the day and not there for the aftrenoon and I select "absent" for the afternoon then I want partcipant field green to match the absent from thr dropdown list. The same if they recycle or exited. Digital form 5.jpgexpand image

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 ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

I'm sorry, but you didn't really answer my question. In your examples all the options are the same. The question is what should happen if they are not the same.

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 Beginner ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

If the form is completed correctly, there should not be mulitle selection. However Exited "red" should override any other choice. Recycle "yellow" overrides absent or tardy "green". I can eleminate Tardy if needed.

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 ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

LATEST

OK, now it's more clear. You can use this code as the custom calculation script of the Participant Name fields:

 

var rowNumber = event.target.name.replace("PARTICIPANT NAMERow", "");
var fields = ["STP-"+rowNumber, "LOP-"+rowNumber, "LIP-"+rowNumber, "ETP-"+rowNumber];
var bAbsent = false;
var bTardy = false;
var bExited = false;
var bRecycle = false;
for (var i in fields) {
	var f = this.getField(fields[i]);
	var v = f.valueAsString;
	if (v=="bAbsent") bAbsent = true;
	if (v=="Tardy") bTardy = true;
	if (v=="Exited") bExited = true;
	if (v=="Recycle") bRecycle = true;
}

if (bExited) event.target.fillColor = color.red;
else if (bRecycle) event.target.fillColor = color.yellow;
else if (bAbsent || bTardy) event.target.fillColor = color.green;
else event.target.fillColor = color.transparent;

 

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